Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,17 +27,20 @@ def ai_response(message, chat_history):
|
|
| 27 |
|
| 28 |
return assistant_message, chat_history
|
| 29 |
|
| 30 |
-
# 创建 Gradio
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
message_input.submit(ai_response, inputs=[message_input, chat_interface], outputs=[output_message, chat_interface])
|
| 41 |
|
| 42 |
# 启动 Gradio 应用
|
|
|
|
| 43 |
demo.launch()
|
|
|
|
| 27 |
|
| 28 |
return assistant_message, chat_history
|
| 29 |
|
| 30 |
+
# 创建 Gradio 应用
|
| 31 |
+
def create_interface():
|
| 32 |
+
with gr.Blocks() as demo:
|
| 33 |
+
# 创建一个文本框用于输入消息
|
| 34 |
+
message_input = gr.Textbox(label="请输入你的问题")
|
| 35 |
+
|
| 36 |
+
# 创建一个聊天机器人输出组件,用于显示对话
|
| 37 |
+
chat_output = gr.Chatbot()
|
| 38 |
+
|
| 39 |
+
# 提交按钮,发送用户消息并获取AI回复
|
| 40 |
+
message_input.submit(ai_response, inputs=[message_input, chat_output], outputs=[chat_output])
|
| 41 |
|
| 42 |
+
return demo
|
|
|
|
| 43 |
|
| 44 |
# 启动 Gradio 应用
|
| 45 |
+
demo = create_interface()
|
| 46 |
demo.launch()
|