Spaces:
Runtime error
Runtime error
Commit
·
ba4c612
1
Parent(s):
c72bfe4
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from PIL import Image
|
|
3 |
import io
|
4 |
import base64
|
5 |
|
6 |
-
# Assuming google.generativeai as genai is the correct import based on your description
|
7 |
import google.generativeai as genai
|
8 |
|
9 |
# Configure the API key (should be set as an environment variable or secure storage in production)
|
@@ -47,8 +46,8 @@ def get_image_base64(image):
|
|
47 |
img_str = base64.b64encode(buffered.getvalue()).decode()
|
48 |
return img_str
|
49 |
|
50 |
-
#
|
51 |
-
|
52 |
if user_input or uploaded_files:
|
53 |
# Save user input to the chat history
|
54 |
if user_input:
|
@@ -85,7 +84,10 @@ if st.button("Send", key="send_button"):
|
|
85 |
st.session_state['chat_history'].append(("Gemini", response_text))
|
86 |
|
87 |
# Clear the input box after sending the message
|
88 |
-
st.session_state
|
|
|
|
|
|
|
89 |
|
90 |
# Re-display the chat history to include the new messages
|
91 |
for message in st.session_state['chat_history']:
|
|
|
3 |
import io
|
4 |
import base64
|
5 |
|
|
|
6 |
import google.generativeai as genai
|
7 |
|
8 |
# Configure the API key (should be set as an environment variable or secure storage in production)
|
|
|
46 |
img_str = base64.b64encode(buffered.getvalue()).decode()
|
47 |
return img_str
|
48 |
|
49 |
+
# Callback function to send message and clear input
|
50 |
+
def send_message():
|
51 |
if user_input or uploaded_files:
|
52 |
# Save user input to the chat history
|
53 |
if user_input:
|
|
|
84 |
st.session_state['chat_history'].append(("Gemini", response_text))
|
85 |
|
86 |
# Clear the input box after sending the message
|
87 |
+
st.session_state.user_input = ""
|
88 |
+
|
89 |
+
# When the 'Send' button is clicked, call the send_message callback
|
90 |
+
send_button = st.button("Send", key="send_button", on_click=send_message)
|
91 |
|
92 |
# Re-display the chat history to include the new messages
|
93 |
for message in st.session_state['chat_history']:
|