Spaces:
Runtime error
Runtime error
mkw18
commited on
Commit
·
f7c5b52
1
Parent(s):
33c4d36
fix
Browse files
app.py
CHANGED
|
@@ -245,16 +245,16 @@ def reset_state(zh, request: gr.Request):
|
|
| 245 |
return chatbot, messages, gr.update(value=""), gr.update(value="显示答案") if zh else gr.update(value="Show Answer"), answer, idx, gr.update(value=data['story'].strip()), False, story_key, answer_key, [], 0, [], [], zh
|
| 246 |
|
| 247 |
|
| 248 |
-
def zh_en_trans(zh):
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
zh = not zh
|
| 259 |
data = {'refresh': zh}
|
| 260 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
|
@@ -327,6 +327,6 @@ with gr.Blocks() as demo:
|
|
| 327 |
|
| 328 |
emptyBtn.click(reset_state, [zh], [chatbot, messages, answer_output, answerBtn, answer, idx, question, show_ans, story_key, answer_key, known, bingo, reasoning, history, zh], show_progress=True)
|
| 329 |
|
| 330 |
-
answerBtn.click(show_hide_answer, [answer, show_ans, zh],
|
| 331 |
|
| 332 |
demo.queue().launch()
|
|
|
|
| 245 |
return chatbot, messages, gr.update(value=""), gr.update(value="显示答案") if zh else gr.update(value="Show Answer"), answer, idx, gr.update(value=data['story'].strip()), False, story_key, answer_key, [], 0, [], [], zh
|
| 246 |
|
| 247 |
|
| 248 |
+
def zh_en_trans(zh, request: gr.Request):
|
| 249 |
+
global host_cnt
|
| 250 |
+
host = request.client.host
|
| 251 |
+
if not host in host_cnt:
|
| 252 |
+
host_cnt[host] = time.time()
|
| 253 |
+
else:
|
| 254 |
+
elapse = time.time()-host_cnt[host]
|
| 255 |
+
if elapse < 10:
|
| 256 |
+
time.sleep(10-elapse)
|
| 257 |
+
host_cnt[host] = time.time()
|
| 258 |
zh = not zh
|
| 259 |
data = {'refresh': zh}
|
| 260 |
data=requests.post(os.environ.get("URL"), data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
|
|
|
|
| 327 |
|
| 328 |
emptyBtn.click(reset_state, [zh], [chatbot, messages, answer_output, answerBtn, answer, idx, question, show_ans, story_key, answer_key, known, bingo, reasoning, history, zh], show_progress=True)
|
| 329 |
|
| 330 |
+
answerBtn.click(show_hide_answer, [answer, show_ans, zh], [answer_output, answerBtn, show_ans], show_progress=True)
|
| 331 |
|
| 332 |
demo.queue().launch()
|