Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -54,21 +54,22 @@ def generate_response(user_input):
|
|
54 |
|
55 |
# 创建Gradio界面
|
56 |
def chat_interface(user_input, history):
|
57 |
-
global chat_history
|
58 |
response = generate_response(user_input)
|
59 |
-
history.append(
|
|
|
60 |
return "", history
|
61 |
|
62 |
iface = gr.Blocks()
|
63 |
|
64 |
with iface:
|
65 |
gr.Markdown("# 醫療問答助手\n這是一個基於 MediaTek-Research/Breeze-7B-Instruct-v1_0 模型的醫療問答助手。")
|
66 |
-
chatbot = gr.Chatbot()
|
67 |
with gr.Row():
|
68 |
txt = gr.Textbox(
|
69 |
show_label=False,
|
70 |
placeholder="請輸入你的問題...",
|
71 |
-
|
|
|
72 |
txt.submit(chat_interface, [txt, chatbot], [txt, chatbot])
|
73 |
|
74 |
# 启动Gradio界面并共享链接
|
|
|
54 |
|
55 |
# 创建Gradio界面
|
56 |
def chat_interface(user_input, history):
|
|
|
57 |
response = generate_response(user_input)
|
58 |
+
history.append({"role": "user", "content": user_input})
|
59 |
+
history.append({"role": "assistant", "content": response})
|
60 |
return "", history
|
61 |
|
62 |
iface = gr.Blocks()
|
63 |
|
64 |
with iface:
|
65 |
gr.Markdown("# 醫療問答助手\n這是一個基於 MediaTek-Research/Breeze-7B-Instruct-v1_0 模型的醫療問答助手。")
|
66 |
+
chatbot = gr.Chatbot(type="messages") # 使用OpenAI风格的字典格式
|
67 |
with gr.Row():
|
68 |
txt = gr.Textbox(
|
69 |
show_label=False,
|
70 |
placeholder="請輸入你的問題...",
|
71 |
+
lines=1,
|
72 |
+
)
|
73 |
txt.submit(chat_interface, [txt, chatbot], [txt, chatbot])
|
74 |
|
75 |
# 启动Gradio界面并共享链接
|