Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -43,25 +43,22 @@ def bot_response(
|
|
43 |
if not text_prompt.strip():
|
44 |
return chatbot, "Por favor, escribe un mensaje válido."
|
45 |
|
|
|
46 |
model = genai.GenerativeModel(
|
47 |
model_name=model_choice,
|
48 |
generation_config=generation_config,
|
49 |
system_instruction=system_instruction or "You are an assistant."
|
50 |
)
|
51 |
|
|
|
52 |
response = model.generate_content([text_prompt], stream=True, generation_config=generation_config)
|
53 |
|
54 |
-
#
|
55 |
generated_text = ""
|
56 |
for chunk in response:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
time.sleep(0.01)
|
61 |
-
chatbot.append((text_prompt, generated_text))
|
62 |
-
yield chatbot, ""
|
63 |
-
|
64 |
-
# Devolver el historial actualizado
|
65 |
chatbot.append((text_prompt, generated_text))
|
66 |
return chatbot, ""
|
67 |
|
|
|
43 |
if not text_prompt.strip():
|
44 |
return chatbot, "Por favor, escribe un mensaje válido."
|
45 |
|
46 |
+
# Configurar el modelo
|
47 |
model = genai.GenerativeModel(
|
48 |
model_name=model_choice,
|
49 |
generation_config=generation_config,
|
50 |
system_instruction=system_instruction or "You are an assistant."
|
51 |
)
|
52 |
|
53 |
+
# Generar la respuesta
|
54 |
response = model.generate_content([text_prompt], stream=True, generation_config=generation_config)
|
55 |
|
56 |
+
# Construir la respuesta completa
|
57 |
generated_text = ""
|
58 |
for chunk in response:
|
59 |
+
generated_text += chunk.text
|
60 |
+
|
61 |
+
# Actualizar el historial del chatbot con una sola entrada
|
|
|
|
|
|
|
|
|
|
|
62 |
chatbot.append((text_prompt, generated_text))
|
63 |
return chatbot, ""
|
64 |
|