Spaces:
Runtime error
Runtime error
mkw18
commited on
Commit
·
2f62962
1
Parent(s):
91fc045
fix chat
Browse files
app.py
CHANGED
@@ -76,7 +76,7 @@ def predict(input, chatbot, messages):
|
|
76 |
# messages.append({"role": "assistant", "content": response})
|
77 |
# data = {'predict': messages}
|
78 |
# requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8'))
|
79 |
-
data = {'predict': messages}
|
80 |
response=str(requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content, encoding="utf-8")
|
81 |
chatbot[-1] = (parse_text(input), parse_text(response))
|
82 |
messages.append({"role": "assistant", "content": response})
|
@@ -89,12 +89,14 @@ def reset_user_input():
|
|
89 |
|
90 |
def reset_state():
|
91 |
global answer
|
|
|
92 |
data = {'refresh': ''}
|
93 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
94 |
data = json.loads(str(data, encoding="utf-8"))
|
95 |
chatbot = data['chatbot']
|
96 |
messages = data['messages']
|
97 |
answer = data['answer']
|
|
|
98 |
return chatbot, messages, gr.update(value=""), gr.update(value="Show Answer")
|
99 |
|
100 |
|
@@ -116,7 +118,10 @@ with gr.Blocks() as demo:
|
|
116 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
117 |
data = json.loads(str(data, encoding="utf-8"))
|
118 |
chatbot = gr.Chatbot(data['chatbot'])
|
|
|
|
|
119 |
answer = data['answer']
|
|
|
120 |
with gr.Row():
|
121 |
with gr.Column(scale=4):
|
122 |
with gr.Column(scale=12):
|
|
|
76 |
# messages.append({"role": "assistant", "content": response})
|
77 |
# data = {'predict': messages}
|
78 |
# requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8'))
|
79 |
+
data = {'predict': messages, 'filepath': filepath}
|
80 |
response=str(requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content, encoding="utf-8")
|
81 |
chatbot[-1] = (parse_text(input), parse_text(response))
|
82 |
messages.append({"role": "assistant", "content": response})
|
|
|
89 |
|
90 |
def reset_state():
|
91 |
global answer
|
92 |
+
global filepath
|
93 |
data = {'refresh': ''}
|
94 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
95 |
data = json.loads(str(data, encoding="utf-8"))
|
96 |
chatbot = data['chatbot']
|
97 |
messages = data['messages']
|
98 |
answer = data['answer']
|
99 |
+
filepath = data['filepath']
|
100 |
return chatbot, messages, gr.update(value=""), gr.update(value="Show Answer")
|
101 |
|
102 |
|
|
|
118 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
119 |
data = json.loads(str(data, encoding="utf-8"))
|
120 |
chatbot = gr.Chatbot(data['chatbot'])
|
121 |
+
global answer
|
122 |
+
global filepath
|
123 |
answer = data['answer']
|
124 |
+
filepath = data['filepath']
|
125 |
with gr.Row():
|
126 |
with gr.Column(scale=4):
|
127 |
with gr.Column(scale=12):
|