Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -143,12 +143,14 @@ def process_model_response(prompt, max_retries=3):
|
|
143 |
return False
|
144 |
|
145 |
def handle_example_click(prompt_text):
|
|
|
146 |
st.session_state.update({
|
147 |
'show_examples': False,
|
148 |
'messages': [],
|
149 |
'current_chat_id': str(time.time()),
|
150 |
'gemini_history': [],
|
151 |
-
'chat_title': 'Nuevo Chat'
|
|
|
152 |
})
|
153 |
|
154 |
if st.session_state.current_chat_id not in st.session_state.chats_in_memory:
|
@@ -288,10 +290,20 @@ if st.session_state.show_examples and not st.session_state.messages:
|
|
288 |
st.markdown("---")
|
289 |
|
290 |
# === ENTRADA DEL USUARIO ===
|
291 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
with st.chat_message("user", avatar=USER_AVATAR_ICON):
|
293 |
-
st.markdown(
|
294 |
-
add_message("user",
|
|
|
|
|
|
|
295 |
|
296 |
is_first_message = len(st.session_state.messages) == 0
|
297 |
|
|
|
143 |
return False
|
144 |
|
145 |
def handle_example_click(prompt_text):
|
146 |
+
"""Función para manejar clicks en ejemplos"""
|
147 |
st.session_state.update({
|
148 |
'show_examples': False,
|
149 |
'messages': [],
|
150 |
'current_chat_id': str(time.time()),
|
151 |
'gemini_history': [],
|
152 |
+
'chat_title': 'Nuevo Chat',
|
153 |
+
'user_input': prompt_text # Añadir el texto al estado
|
154 |
})
|
155 |
|
156 |
if st.session_state.current_chat_id not in st.session_state.chats_in_memory:
|
|
|
290 |
st.markdown("---")
|
291 |
|
292 |
# === ENTRADA DEL USUARIO ===
|
293 |
+
if 'user_input' in st.session_state:
|
294 |
+
prompt = st.session_state.user_input
|
295 |
+
del st.session_state.user_input # Limpiar después de usar
|
296 |
+
else:
|
297 |
+
prompt = st.chat_input('¿En qué puedo ayudarte hoy?')
|
298 |
+
|
299 |
+
if prompt:
|
300 |
+
# Simular el envío del mensaje
|
301 |
with st.chat_message("user", avatar=USER_AVATAR_ICON):
|
302 |
+
st.markdown(prompt_text)
|
303 |
+
add_message("user", prompt_text, USER_AVATAR_ICON)
|
304 |
+
|
305 |
+
# Procesar la respuesta
|
306 |
+
process_model_response(prompt_text)
|
307 |
|
308 |
is_first_message = len(st.session_state.messages) == 0
|
309 |
|