Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
|
@@ -32,7 +33,12 @@ def load_conversation(conversation_id):
|
|
| 32 |
else:
|
| 33 |
return []
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
gr.Markdown("# Groq Chatbot with Conversation Persistence")
|
| 37 |
|
| 38 |
with gr.Row():
|
|
@@ -43,15 +49,9 @@ with gr.Blocks() as iface:
|
|
| 43 |
msg = gr.Textbox()
|
| 44 |
clear = gr.Button("Clear")
|
| 45 |
|
| 46 |
-
def respond(message, chat_history):
|
| 47 |
-
bot_message = chat_with_groq(message, chat_history)
|
| 48 |
-
chat_history.append((message, bot_message))
|
| 49 |
-
return "", chat_history
|
| 50 |
-
|
| 51 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 52 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 53 |
|
| 54 |
load_button.click(load_conversation, inputs=[conversation_id_input], outputs=[chatbot])
|
| 55 |
|
| 56 |
-
|
| 57 |
-
iface.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
|
|
|
|
| 33 |
else:
|
| 34 |
return []
|
| 35 |
|
| 36 |
+
def respond(message, chat_history):
|
| 37 |
+
bot_message = chat_with_groq(message, chat_history)
|
| 38 |
+
chat_history.append((message, bot_message))
|
| 39 |
+
return "", chat_history
|
| 40 |
+
|
| 41 |
+
with gr.Blocks() as demo:
|
| 42 |
gr.Markdown("# Groq Chatbot with Conversation Persistence")
|
| 43 |
|
| 44 |
with gr.Row():
|
|
|
|
| 49 |
msg = gr.Textbox()
|
| 50 |
clear = gr.Button("Clear")
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 53 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 54 |
|
| 55 |
load_button.click(load_conversation, inputs=[conversation_id_input], outputs=[chatbot])
|
| 56 |
|
| 57 |
+
demo.launch()
|
|
|