Spaces:
Runtime error
Runtime error
mkw18
commited on
Commit
·
1fdbadb
1
Parent(s):
2f62962
fix answer
Browse files
app.py
CHANGED
@@ -88,7 +88,6 @@ def reset_user_input():
|
|
88 |
|
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
|
@@ -97,10 +96,10 @@ def reset_state():
|
|
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 |
|
103 |
-
def show_hide_answer():
|
104 |
global show_ans
|
105 |
if show_ans:
|
106 |
show_ans = False
|
@@ -118,9 +117,8 @@ with gr.Blocks() as demo:
|
|
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):
|
@@ -142,8 +140,8 @@ with gr.Blocks() as demo:
|
|
142 |
show_progress=True)
|
143 |
submitBtn.click(reset_user_input, [], [user_input])
|
144 |
|
145 |
-
emptyBtn.click(reset_state, outputs=[chatbot, messages, answer_output, answerBtn], show_progress=True)
|
146 |
|
147 |
-
answerBtn.click(show_hide_answer, outputs=[answer_output, answerBtn])
|
148 |
|
149 |
demo.queue().launch()
|
|
|
88 |
|
89 |
|
90 |
def reset_state():
|
|
|
91 |
global filepath
|
92 |
data = {'refresh': ''}
|
93 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
|
|
96 |
messages = data['messages']
|
97 |
answer = data['answer']
|
98 |
filepath = data['filepath']
|
99 |
+
return chatbot, messages, gr.update(value=""), gr.update(value="Show Answer"), answer
|
100 |
|
101 |
|
102 |
+
def show_hide_answer(answer):
|
103 |
global show_ans
|
104 |
if show_ans:
|
105 |
show_ans = False
|
|
|
117 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
118 |
data = json.loads(str(data, encoding="utf-8"))
|
119 |
chatbot = gr.Chatbot(data['chatbot'])
|
|
|
120 |
global filepath
|
121 |
+
answer = gr.State(data['answer'])
|
122 |
filepath = data['filepath']
|
123 |
with gr.Row():
|
124 |
with gr.Column(scale=4):
|
|
|
140 |
show_progress=True)
|
141 |
submitBtn.click(reset_user_input, [], [user_input])
|
142 |
|
143 |
+
emptyBtn.click(reset_state, outputs=[chatbot, messages, answer_output, answerBtn, answer], show_progress=True)
|
144 |
|
145 |
+
answerBtn.click(show_hide_answer, [answer], outputs=[answer_output, answerBtn])
|
146 |
|
147 |
demo.queue().launch()
|