Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
-
from chat import generate_response
|
| 4 |
|
| 5 |
def gradio_interface(user_input, max_tokens, temperature):
|
| 6 |
return generate_response(user_input, max_length=max_tokens, temperature=temperature)
|
|
@@ -14,8 +14,24 @@ iface = gr.Interface(
|
|
| 14 |
],
|
| 15 |
outputs="text",
|
| 16 |
title="ChatGpt Tune",
|
| 17 |
-
description="Chat with your Hugging Face model
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if __name__ == "__main__":
|
| 21 |
-
|
|
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
+
from chat import generate_response, reset_conversation
|
| 4 |
|
| 5 |
def gradio_interface(user_input, max_tokens, temperature):
|
| 6 |
return generate_response(user_input, max_length=max_tokens, temperature=temperature)
|
|
|
|
| 14 |
],
|
| 15 |
outputs="text",
|
| 16 |
title="ChatGpt Tune",
|
| 17 |
+
description="Chat with your Hugging Face model. Supports multi-turn conversation!"
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# Optional: add a reset button for conversation memory
|
| 21 |
+
def reset_button():
|
| 22 |
+
return reset_conversation()
|
| 23 |
+
|
| 24 |
+
reset_iface = gr.Interface(
|
| 25 |
+
fn=reset_button,
|
| 26 |
+
inputs=[],
|
| 27 |
+
outputs="text",
|
| 28 |
+
live=False,
|
| 29 |
+
title="Reset Conversation",
|
| 30 |
+
description="Click to clear conversation memory."
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# Combine interfaces into a single Gradio app
|
| 34 |
+
demo = gr.TabbedInterface([iface, reset_iface], ["Chat", "Reset Conversation"])
|
| 35 |
+
|
| 36 |
if __name__ == "__main__":
|
| 37 |
+
demo.launch(share=True)
|