Spaces:
Running
Running
Upload 10 files
Browse files
app.py
CHANGED
@@ -32,9 +32,6 @@ load_dotenv()
|
|
32 |
GOOGLE_API_KEY=os.environ.get('GOOGLE_API_KEY')
|
33 |
genai.configure(api_key=GOOGLE_API_KEY)
|
34 |
|
35 |
-
# Inicializar el cliente de Gemini
|
36 |
-
client = genai.Client(api_key=GOOGLE_API_KEY)
|
37 |
-
|
38 |
new_chat_id = f'{time.time()}'
|
39 |
MODEL_ROLE = 'ai'
|
40 |
AI_AVATAR_ICON = '🤖' # Cambia el emoji por uno de robot para coincidir con tu logo
|
@@ -158,29 +155,16 @@ if prompt := st.chat_input('¿En qué puedo ayudarte con tu Propuesta Única de
|
|
158 |
# Obtener el system prompt iterativo
|
159 |
system_prompt = get_puv_system_prompt()
|
160 |
|
161 |
-
#
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
parts=[
|
166 |
-
types.Part.from_text(text=prompt),
|
167 |
-
],
|
168 |
-
),
|
169 |
-
]
|
170 |
-
|
171 |
-
# Configurar el system prompt
|
172 |
-
generate_content_config = types.GenerateContentConfig(
|
173 |
-
response_mime_type="text/plain",
|
174 |
-
system_instruction=[
|
175 |
-
types.Part.from_text(text=system_prompt),
|
176 |
-
],
|
177 |
)
|
178 |
|
179 |
# Enviar mensaje al AI con system prompt
|
180 |
-
response_stream =
|
181 |
-
|
182 |
-
|
183 |
-
config=generate_content_config,
|
184 |
)
|
185 |
|
186 |
# Display assistant response in chat message container
|
|
|
32 |
GOOGLE_API_KEY=os.environ.get('GOOGLE_API_KEY')
|
33 |
genai.configure(api_key=GOOGLE_API_KEY)
|
34 |
|
|
|
|
|
|
|
35 |
new_chat_id = f'{time.time()}'
|
36 |
MODEL_ROLE = 'ai'
|
37 |
AI_AVATAR_ICON = '🤖' # Cambia el emoji por uno de robot para coincidir con tu logo
|
|
|
155 |
# Obtener el system prompt iterativo
|
156 |
system_prompt = get_puv_system_prompt()
|
157 |
|
158 |
+
# Crear una instancia del modelo con el system prompt
|
159 |
+
model = genai.GenerativeModel(
|
160 |
+
model_name='gemini-2.0-flash',
|
161 |
+
system_instruction=system_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
)
|
163 |
|
164 |
# Enviar mensaje al AI con system prompt
|
165 |
+
response_stream = model.generate_content(
|
166 |
+
prompt,
|
167 |
+
stream=True,
|
|
|
168 |
)
|
169 |
|
170 |
# Display assistant response in chat message container
|