Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import google.generativeai as genai
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
# Configure the API key
|
| 6 |
-
genai.configure(api_key=os.environ["
|
| 7 |
|
| 8 |
# Create the model
|
| 9 |
generation_config = {
|
|
@@ -48,4 +48,12 @@ with gr.Blocks() as demo:
|
|
| 48 |
show_label=False,
|
| 49 |
placeholder="Type your message and press Enter"
|
| 50 |
)
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
# Configure the API key
|
| 6 |
+
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
| 7 |
|
| 8 |
# Create the model
|
| 9 |
generation_config = {
|
|
|
|
| 48 |
show_label=False,
|
| 49 |
placeholder="Type your message and press Enter"
|
| 50 |
)
|
| 51 |
+
send_btn = gr.Button("Send") # Ensure this line uses 'send_btn'
|
| 52 |
+
# Event handlers
|
| 53 |
+
send_btn.click(chat_with_model, [user_input, state], [chatbot, state])
|
| 54 |
+
user_input.submit(chat_with_model, [user_input, state], [chatbot, state])
|
| 55 |
+
# Clear input after sending
|
| 56 |
+
send_btn.click(lambda: "", None, user_input)
|
| 57 |
+
user_input.submit(lambda: "", None, user_input)
|
| 58 |
+
|
| 59 |
+
demo.launch()
|