Spaces:
Runtime error
Runtime error
Commit
·
bca4310
1
Parent(s):
20e79b2
Add application file for the start
Browse files
app.py
CHANGED
@@ -35,8 +35,9 @@ class Conversation:
|
|
35 |
|
36 |
|
37 |
|
|
|
38 |
import gradio as gr
|
39 |
-
prompt = """
|
40 |
1. 你的回答必须是中文
|
41 |
2. 回答限制在100个字以内"""
|
42 |
|
@@ -49,13 +50,20 @@ def answer(question, history=[]):
|
|
49 |
responses = [(u,b) for u,b in zip(history[::2], history[1::2])]
|
50 |
return responses, history
|
51 |
|
|
|
|
|
|
|
52 |
with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as demo:
|
|
|
53 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
54 |
state = gr.State([])
|
55 |
-
print('你好,我是一位资深心理咨询师,可以帮你解答情感问题,你有什么想要问我的吗?')
|
56 |
-
with gr.Row():
|
57 |
-
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
|
58 |
-
|
59 |
-
txt.submit(answer, [txt, state], [chatbot, state])
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
demo.launch()
|
|
|
35 |
|
36 |
|
37 |
|
38 |
+
|
39 |
import gradio as gr
|
40 |
+
prompt = """你是一个中国资深心理咨询师,你的名字叫李诞,用李诞的语气及中文回答情感的问题。你的回答需要满足以下要求:
|
41 |
1. 你的回答必须是中文
|
42 |
2. 回答限制在100个字以内"""
|
43 |
|
|
|
50 |
responses = [(u,b) for u,b in zip(history[::2], history[1::2])]
|
51 |
return responses, history
|
52 |
|
53 |
+
|
54 |
+
def clear_input():
|
55 |
+
return "",""
|
56 |
with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as demo:
|
57 |
+
gr.Markdown('你好,我是一位资深心理咨询师,可以帮你解答情感问题,你有什么想要问我的吗?')
|
58 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
59 |
state = gr.State([])
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
with gr.Row():
|
62 |
+
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=True)
|
63 |
+
with gr.Row():
|
64 |
+
submit = gr.Button("Sbumit")
|
65 |
+
clear = gr.Button("Clear")
|
66 |
+
txt.submit(answer, [txt, state], [chatbot, state])
|
67 |
+
submit.click(answer,inputs=[txt], outputs=[chatbot,state])
|
68 |
+
clear.click(clear_input,inputs=[],outputs=[txt,chatbot])
|
69 |
demo.launch()
|