Spaces:
Sleeping
Sleeping
BenBranyon
commited on
Commit
•
256a97d
1
Parent(s):
dabde3e
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import requests
|
4 |
import json
|
|
|
5 |
|
6 |
#from huggingface_hub.inference_api import InferenceApi
|
7 |
#inference = InferenceApi(repo_id="BenBranyon/tinyllama-sumbot-peft", token=os.environ['HF_TOKEN'])
|
@@ -17,13 +18,11 @@ def query(payload):
|
|
17 |
response = requests.request("POST", API_URL, headers=headers, data=data)
|
18 |
try:
|
19 |
data = json.loads(response.content.decode("utf-8"))
|
20 |
-
|
|
|
21 |
return response
|
22 |
except:
|
23 |
return response
|
24 |
-
#response = inference(payload)
|
25 |
-
#response = requests.post(API_URL, headers=headers, json=payload)
|
26 |
-
#return response.json()
|
27 |
|
28 |
messages = st.container()
|
29 |
message = st.chat_message("assistant").write("Hello human")
|
|
|
2 |
import os
|
3 |
import requests
|
4 |
import json
|
5 |
+
import re
|
6 |
|
7 |
#from huggingface_hub.inference_api import InferenceApi
|
8 |
#inference = InferenceApi(repo_id="BenBranyon/tinyllama-sumbot-peft", token=os.environ['HF_TOKEN'])
|
|
|
18 |
response = requests.request("POST", API_URL, headers=headers, data=data)
|
19 |
try:
|
20 |
data = json.loads(response.content.decode("utf-8"))
|
21 |
+
generated_text = data[0]['generated_text']
|
22 |
+
reponse = re.sub('\n<|system|>.*?<|assistant|>','',generated_text, flags=re.DOTALL)
|
23 |
return response
|
24 |
except:
|
25 |
return response
|
|
|
|
|
|
|
26 |
|
27 |
messages = st.container()
|
28 |
message = st.chat_message("assistant").write("Hello human")
|