Dibiddo commited on
Commit
efc5651
·
verified ·
1 Parent(s): 6e29a0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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((user_input, 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()
67
  with gr.Row():
68
  txt = gr.Textbox(
69
  show_label=False,
70
  placeholder="請輸入你的問題...",
71
- ).style(container=False)
 
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界面并共享链接