JeCabrera commited on
Commit
1781efb
·
verified ·
1 Parent(s): a5e9800

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -24
app.py CHANGED
@@ -123,6 +123,13 @@ INSTRUCCIONES CRÍTICAS PARA TODAS LAS FÓRMULAS:
123
  - NO incluyas explicaciones sobre por qué la PUV es efectiva
124
  - SOLO presenta la PUV, nada más
125
 
 
 
 
 
 
 
 
126
  IMPORTANTE: Cuando el usuario pregunte por tus funciones o capacidades, responde siempre en primera persona singular (yo hago, yo creo, yo analizo) de forma breve y concisa. No menciones que eres un equipo de expertos, sino un asistente especializado en crear PUVs.
127
  """
128
 
@@ -199,46 +206,45 @@ with st.sidebar:
199
  st.image("assets/robocopy_logo.png", width=300)
200
 
201
  st.write('# Chats Anteriores')
202
- if st.session_state.get('chat_id') is None:
203
- st.session_state.chat_id = st.selectbox(
204
  label='Selecciona un chat anterior',
205
- options=[new_chat_id] + list(past_chats.keys()),
206
- format_func=lambda x: past_chats.get(x, 'Nuevo Chat'),
207
  placeholder='_',
208
  )
209
  else:
210
- # This will happen the first time AI response comes in
211
- st.session_state.chat_id = st.selectbox(
212
  label='Selecciona un chat anterior',
213
- options=[new_chat_id, st.session_state.chat_id] + list(past_chats.keys()),
214
  index=1,
215
- format_func=lambda x: past_chats.get(x, 'Nuevo Chat' if x != st.session_state.chat_id else st.session_state.chat_title),
216
  placeholder='_',
217
  )
218
 
219
- # Inicializar el título de chat si es necesario
220
- if st.session_state.get('chat_title') is None:
221
- if st.session_state.chat_id in past_chats:
222
- st.session_state.chat_title = past_chats[st.session_state.chat_id]
223
- else:
 
224
  st.session_state.chat_title = 'Nuevo Chat'
225
-
226
- st.write('# Creador de Propuestas Únicas de Valor')
227
 
228
  # Inicializar mensajes y cargar historial
229
  if not st.session_state.get('messages'):
230
  st.session_state.messages = []
231
 
232
- # Cargar historial de chat si existe
233
- try:
234
- st.session_state.messages = joblib.load(f'data/{st.session_state.chat_id}-st_messages')
235
- st.session_state.gemini_history = joblib.load(f'data/{st.session_state.chat_id}-gemini_messages')
236
- print('old cache')
237
- except:
238
- if not st.session_state.get('messages'):
239
- st.session_state.messages = []
240
  st.session_state.gemini_history = []
241
- print('new_cache made')
242
 
243
  # Configuración del modelo
244
  model = genai.GenerativeModel(model_name='gemini-2.0-flash')
 
123
  - NO incluyas explicaciones sobre por qué la PUV es efectiva
124
  - SOLO presenta la PUV, nada más
125
 
126
+ COMPORTAMIENTO COMO AGENTE:
127
+ - Al final de CADA respuesta, SIEMPRE pregunta al usuario qué más le gustaría hacer
128
+ - Ofrece opciones específicas como: mejorar las PUVs, refinarlas, cambiar de fórmula, o crear nuevas para otro producto/servicio
129
+ - Actúa como un agente proactivo que busca satisfacer al usuario
130
+ - Muestra entusiasmo por ayudar y ofrece sugerencias concretas para continuar
131
+ - Mantén un tono conversacional y amigable en todo momento
132
+
133
  IMPORTANTE: Cuando el usuario pregunte por tus funciones o capacidades, responde siempre en primera persona singular (yo hago, yo creo, yo analizo) de forma breve y concisa. No menciones que eres un equipo de expertos, sino un asistente especializado en crear PUVs.
134
  """
135
 
 
206
  st.image("assets/robocopy_logo.png", width=300)
207
 
208
  st.write('# Chats Anteriores')
209
+ if st.session_state.get('current_chat_id') is None:
210
+ st.session_state.current_chat_id = st.selectbox(
211
  label='Selecciona un chat anterior',
212
+ options=[new_chat_id] + list(st.session_state.chats_in_memory.keys()),
213
+ format_func=lambda x: st.session_state.chats_in_memory.get(x, 'Nuevo Chat'),
214
  placeholder='_',
215
  )
216
  else:
217
+ st.session_state.current_chat_id = st.selectbox(
 
218
  label='Selecciona un chat anterior',
219
+ options=[new_chat_id, st.session_state.current_chat_id] + list(st.session_state.chats_in_memory.keys()),
220
  index=1,
221
+ format_func=lambda x: st.session_state.chats_in_memory.get(x, 'Nuevo Chat' if x != st.session_state.current_chat_id else st.session_state.chat_title),
222
  placeholder='_',
223
  )
224
 
225
+ # Botón para borrar el historial
226
+ if st.button('🗑️ Borrar Historial de Chat Actual'):
227
+ if st.session_state.current_chat_id in st.session_state.chats_in_memory:
228
+ del st.session_state.chats_in_memory[st.session_state.current_chat_id]
229
+ st.session_state.messages = []
230
+ st.session_state.gemini_history = []
231
  st.session_state.chat_title = 'Nuevo Chat'
232
+ st.rerun()
 
233
 
234
  # Inicializar mensajes y cargar historial
235
  if not st.session_state.get('messages'):
236
  st.session_state.messages = []
237
 
238
+ # Cargar historial de chat si existe en memoria
239
+ if st.session_state.current_chat_id in st.session_state.chats_in_memory:
240
+ chat_data = st.session_state.chats_in_memory[st.session_state.current_chat_id]
241
+ st.session_state.messages = chat_data.get('messages', [])
242
+ st.session_state.gemini_history = chat_data.get('gemini_history', [])
243
+ st.session_state.chat_title = chat_data.get('title', 'Nuevo Chat')
244
+ else:
245
+ st.session_state.messages = []
246
  st.session_state.gemini_history = []
247
+ st.session_state.chat_title = 'Nuevo Chat'
248
 
249
  # Configuración del modelo
250
  model = genai.GenerativeModel(model_name='gemini-2.0-flash')