Update app.py
Browse files
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 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 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()
|