Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,14 +30,16 @@ def ai_response(message, chat_history):
|
|
| 30 |
# 创建 Gradio 应用
|
| 31 |
def create_interface():
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
chat_output = gr.Chatbot()
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
return demo
|
| 43 |
|
|
|
|
| 30 |
# 创建 Gradio 应用
|
| 31 |
def create_interface():
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
+
# 创建一个 Column 布局,用于将聊天记录和输入框放在同一列
|
| 34 |
+
with gr.Column():
|
| 35 |
+
# 创建一个聊天机器人输出组件,用于显示对话
|
| 36 |
+
chat_output = gr.Chatbot()
|
|
|
|
| 37 |
|
| 38 |
+
# 创建一个文本框用于输入消息
|
| 39 |
+
message_input = gr.Textbox(label="请输入你的问题", placeholder="输入你的问题并按回车发送", lines=1)
|
| 40 |
+
|
| 41 |
+
# 提交按钮,发送用户消息并获取AI回复
|
| 42 |
+
message_input.submit(ai_response, inputs=[message_input, chat_output], outputs=[chat_output])
|
| 43 |
|
| 44 |
return demo
|
| 45 |
|