JeCabrera commited on
Commit
d6a1a2a
·
verified ·
1 Parent(s): 5c64156

Upload 10 files

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -156,25 +156,27 @@ if prompt := st.chat_input('¿En qué puedo ayudarte con tu Propuesta Única de
156
  # Obtener el system prompt iterativo
157
  system_prompt = get_puv_system_prompt()
158
 
159
- # Configurar el system prompt
160
- generate_content_config = types.GenerateContentConfig(
161
- response_mime_type="text/plain",
162
- system_instruction=[
163
- types.Part.from_text(text=system_prompt),
164
- ],
165
  )
166
 
 
 
 
167
  # Enviar mensaje al AI con system prompt
168
- response = st.session_state.model.generate_content(
169
- prompt,
170
- generation_config=generate_content_config,
171
- stream=True,
172
- )
173
- ## Send message to AI
174
- response = st.session_state.chat.send_message(
175
  prompt,
176
  stream=True,
177
  )
 
 
 
 
 
 
 
178
  # Display assistant response in chat message container
179
  with st.chat_message(
180
  name=MODEL_ROLE,
 
156
  # Obtener el system prompt iterativo
157
  system_prompt = get_puv_system_prompt()
158
 
159
+ # Crear una nueva instancia del modelo con el system prompt
160
+ model_with_system_prompt = genai.GenerativeModel(
161
+ model_name='gemini-2.0-flash',
162
+ system_instruction=system_prompt
 
 
163
  )
164
 
165
+ # Crear un chat con el modelo que tiene el system prompt
166
+ chat_with_system = model_with_system_prompt.start_chat(history=[])
167
+
168
  # Enviar mensaje al AI con system prompt
169
+ response = chat_with_system.send_message(
 
 
 
 
 
 
170
  prompt,
171
  stream=True,
172
  )
173
+
174
+ # Eliminar la línea duplicada que usa st.session_state.chat
175
+ # response = st.session_state.chat.send_message(
176
+ # prompt,
177
+ # stream=True,
178
+ # )
179
+
180
  # Display assistant response in chat message container
181
  with st.chat_message(
182
  name=MODEL_ROLE,