Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,26 +43,32 @@ def respond(
|
|
| 43 |
"""
|
| 44 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 45 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
chatbot = gr.ChatInterface(
|
| 47 |
respond,
|
| 48 |
type="messages",
|
| 49 |
additional_inputs=[
|
| 50 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 51 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 52 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 53 |
-
gr.Slider(
|
| 54 |
-
minimum=0.1,
|
| 55 |
-
maximum=1.0,
|
| 56 |
-
value=0.95,
|
| 57 |
-
step=0.05,
|
| 58 |
-
label="Top-p (nucleus sampling)",
|
| 59 |
-
),
|
| 60 |
],
|
| 61 |
)
|
| 62 |
|
| 63 |
with gr.Blocks() as demo:
|
| 64 |
with gr.Sidebar():
|
| 65 |
gr.LoginButton()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
chatbot.render()
|
| 67 |
|
| 68 |
|
|
|
|
| 43 |
"""
|
| 44 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 45 |
"""
|
| 46 |
+
|
| 47 |
+
# Function to clear chat
|
| 48 |
+
def clear_chat():
|
| 49 |
+
return gr.update(value=[])
|
| 50 |
+
|
| 51 |
chatbot = gr.ChatInterface(
|
| 52 |
respond,
|
| 53 |
type="messages",
|
| 54 |
additional_inputs=[
|
| 55 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
],
|
| 57 |
)
|
| 58 |
|
| 59 |
with gr.Blocks() as demo:
|
| 60 |
with gr.Sidebar():
|
| 61 |
gr.LoginButton()
|
| 62 |
+
|
| 63 |
+
# Define a button outside ChatInterface (but visually below)
|
| 64 |
+
clear_button = gr.Button("🧹 Clear Chat", variant="secondary")
|
| 65 |
+
|
| 66 |
+
# Attach event listener to the button
|
| 67 |
+
clear_button.click(
|
| 68 |
+
fn=clear_chat,
|
| 69 |
+
inputs=None,
|
| 70 |
+
outputs=chatbot
|
| 71 |
+
)
|
| 72 |
chatbot.render()
|
| 73 |
|
| 74 |
|