Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
|
5 |
# 修改本函数,来实现你自己的 chatbot
|
6 |
# p: 对机器人说话的内容
|
@@ -9,8 +9,13 @@ count = 0
|
|
9 |
# 返回值:[type, content]
|
10 |
# 详见 https://huggingface.co/spaces/baixing/hackathon_test/blob/main/bot-api.md
|
11 |
def chat(p, qid, uid):
|
12 |
-
global
|
|
|
|
|
|
|
|
|
13 |
count = count+1
|
|
|
14 |
return ["text", f"{count} 我听到你刚说:{p}"]
|
15 |
|
16 |
iface = gr.Interface(fn=chat,
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
history = {}
|
4 |
|
5 |
# 修改本函数,来实现你自己的 chatbot
|
6 |
# p: 对机器人说话的内容
|
|
|
9 |
# 返回值:[type, content]
|
10 |
# 详见 https://huggingface.co/spaces/baixing/hackathon_test/blob/main/bot-api.md
|
11 |
def chat(p, qid, uid):
|
12 |
+
global history
|
13 |
+
if uid in history:
|
14 |
+
count = history[uid]
|
15 |
+
else:
|
16 |
+
count = 0
|
17 |
count = count+1
|
18 |
+
history[uid] = count
|
19 |
return ["text", f"{count} 我听到你刚说:{p}"]
|
20 |
|
21 |
iface = gr.Interface(fn=chat,
|