hsuwill000 commited on
Commit
f48f0af
·
verified ·
1 Parent(s): 6ed2caf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -36,14 +36,21 @@ def respond(message, history):
36
  print(f"Error: {e}")
37
  return history + [(message, "Sorry, something went wrong. Please try again.")]
38
 
 
 
 
 
39
  # Set up Gradio chat interface
40
- demo = gr.ChatInterface(
41
- fn=respond,
42
- title="Qwen2.5-1.5B-Instruct-openvino",
43
- description="Chat with Qwen2.5-1.5B-Instruct-openvino model.",
44
- examples=["Hello!", "Tell me a joke.", "Explain quantum computing."],
45
- clear_btn="Clear History", # 仅保留 clear_btn
46
- )
 
 
 
47
 
48
  if __name__ == "__main__":
49
  demo.launch()
 
36
  print(f"Error: {e}")
37
  return history + [(message, "Sorry, something went wrong. Please try again.")]
38
 
39
+ # Custom clear function
40
+ def clear_history():
41
+ return []
42
+
43
  # Set up Gradio chat interface
44
+ with gr.Blocks() as demo:
45
+ gr.Markdown("# Qwen2.5-1.5B-Instruct-openvino Chat")
46
+ gr.Markdown("Chat with Qwen2.5-1.5B-Instruct-openvino model.")
47
+
48
+ chatbot = gr.Chatbot()
49
+ msg = gr.Textbox(label="Your Message")
50
+ clear_btn = gr.Button("Clear History")
51
+
52
+ msg.submit(respond, [msg, chatbot], chatbot)
53
+ clear_btn.click(clear_history, None, chatbot, queue=False)
54
 
55
  if __name__ == "__main__":
56
  demo.launch()