Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,8 @@ class Config:
|
|
| 27 |
# La configuración de Firebase se cargará desde la variable de entorno __firebase_config
|
| 28 |
# o se usará la configuración proporcionada por el usuario si no está definida.
|
| 29 |
# En un entorno de producción real, se recomienda usar variables de entorno seguras.
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
# --- Firebase Initialization ---
|
| 33 |
# Intenta inicializar Firebase Admin SDK.
|
|
@@ -205,7 +206,7 @@ NUDGE_DATABASE = [
|
|
| 205 |
Nudge("Antes de seguir con el laburo, ¿ya almorzaste, {user_name}? Una buena comida te da la nafta para seguir.", "bienestar", ["Mediodía/Tarde", "Oficina/Estudio", "Trabajando"], ["almuerzo", "energia"]),
|
| 206 |
|
| 207 |
# Mediodía/Tarde - Aire Libre/Calle
|
| 208 |
-
Nudge("El solcito de la tarde es ideal para recargar pilas, {user_name}. ¡Disfrutá el momento! El {clima_actual} es
|
| 209 |
Nudge("Mirá las nubes, ¿qué formas ves? La imaginación vuela libre, {user_name}.", "bienestar", ["Mediodía/Tarde", "Aire Libre/Calle"], ["nubes", "imaginacion"]),
|
| 210 |
Nudge("Si encontrás un banquito, sentate un rato, {user_name}. Observá la gente, la vida que pasa. ¡Es un 'recreo' para el alma!", "bienestar", ["Mediodía/Tarde", "Aire Libre/Calle"], ["pausa", "observacion"]),
|
| 211 |
|
|
@@ -752,7 +753,7 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 752 |
<script>
|
| 753 |
let recognition;
|
| 754 |
let speaking = false;
|
| 755 |
-
let lastSpokenText = "";
|
| 756 |
const matecitoAvatar = document.getElementById('matecito_avatar');
|
| 757 |
const voiceStatus = document.getElementById('voice_status');
|
| 758 |
const startVoiceButton = document.getElementById('start_voice_button'); // Get the button element
|
|
@@ -960,27 +961,17 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 960 |
)
|
| 961 |
|
| 962 |
# --- Contenido de cada Sección (Ahora en gr.Group o gr.Column) ---
|
| 963 |
-
#
|
| 964 |
-
with gr.Column(elem_id="nudges_section", elem_classes="section-content", visible=False):
|
| 965 |
-
gr.Markdown("<h2 style='color: #10b981;'>¡Che, acá estoy para cebarte un susurro!</h2><p>Contame un poco de tu día y te tiro la posta.</p>")
|
| 966 |
-
chat_history = gr.State([]) # Para mantener el historial del chat
|
| 967 |
-
chatbot = gr.Chatbot(label="Conversación con MateAI", height=300, type='messages') # Added type='messages'
|
| 968 |
-
msg_input = gr.Textbox(label="Contale a MateAI...", placeholder="Ej: 'Estoy en casa, laburando y medio cansado.' o 'Quiero un susurro de bienestar.'")
|
| 969 |
-
|
| 970 |
-
# Botón para enviar el mensaje de texto (además de la entrada de voz)
|
| 971 |
-
btn_send_msg = gr.Button("Enviar Mensaje", variant="primary")
|
| 972 |
-
|
| 973 |
-
# Resto de las secciones (ocultas por defecto)
|
| 974 |
home_section = gr.Column(elem_id="home_section", elem_classes="section-content", visible=True)
|
|
|
|
| 975 |
oracle_section = gr.Column(elem_id="oracle_section", elem_classes="section-content", visible=False)
|
| 976 |
challenges_section = gr.Column(elem_id="challenges_section", elem_classes="section-content", visible=False)
|
| 977 |
-
history_section = gr.Column(elem_id="history_section", elem_classes="section-content", visible=False)
|
| 978 |
tasks_section = gr.Column(elem_id="tasks_section", elem_classes="section-content", visible=False)
|
|
|
|
| 979 |
browser_agent_section = gr.Column(elem_id="browser_agent_section", elem_classes="section-content", visible=False)
|
| 980 |
-
nudges_section = gr.Column(elem_id="nudges_section", elem_classes="section-content", visible=False) # Defined earlier, but need to be included in the outputs list
|
| 981 |
|
| 982 |
with home_section: # Home visible por defecto
|
| 983 |
-
gr.Markdown("<h2 style='color: #10b981;'>¡Bienvenido a tu Espacio MateAI!</h2><p>Acá manejás tu perfil para que MateAI te conozca a fondo.</p>")
|
| 984 |
with gr.Row():
|
| 985 |
with gr.Column():
|
| 986 |
gr.Markdown("<h3 style='color: #38bdf8;'>Crear Nuevo Usuario</h3>")
|
|
@@ -1018,11 +1009,20 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1018 |
label="Frecuencia de susurros",
|
| 1019 |
value="normal"
|
| 1020 |
)
|
| 1021 |
-
modo_che_tranqui_checkbox = gr.Checkbox(label="Activar 'Modo Che, Tranqui' (prioriza calma)", value=False)
|
| 1022 |
|
| 1023 |
btn_actualizar_preferencias = gr.Button("Actualizar Preferencias", variant="primary")
|
| 1024 |
output_actualizar_preferencias = gr.Textbox(label="Estado de Actualización", interactive=False)
|
| 1025 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1026 |
with oracle_section:
|
| 1027 |
gr.Markdown("<h2 style='text-align: center; color: #10b981;'>✨ La Revelación Diaria del Oráculo MateAI ✨</h2><p style='text-align: center;'>Una sabiduría profunda para iluminar tu jornada. El Oráculo te habla una vez al día.</p>")
|
| 1028 |
oraculo_output = gr.Textbox(
|
|
@@ -1146,8 +1146,8 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1146 |
# Create a dictionary to hold updates for each section
|
| 1147 |
updates = {
|
| 1148 |
"home_section": gr.Column.update(visible=False),
|
| 1149 |
-
"oracle_section": gr.Column.update(visible=False),
|
| 1150 |
"nudges_section": gr.Column.update(visible=False),
|
|
|
|
| 1151 |
"challenges_section": gr.Column.update(visible=False),
|
| 1152 |
"history_section": gr.Column.update(visible=False),
|
| 1153 |
"tasks_section": gr.Column.update(visible=False),
|
|
@@ -1159,8 +1159,8 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1159 |
# Return the updates in a consistent order, followed by the state update
|
| 1160 |
return (
|
| 1161 |
updates["home_section"],
|
| 1162 |
-
updates["oracle_section"],
|
| 1163 |
updates["nudges_section"],
|
|
|
|
| 1164 |
updates["challenges_section"],
|
| 1165 |
updates["history_section"],
|
| 1166 |
updates["tasks_section"],
|
|
@@ -1288,14 +1288,15 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1288 |
response = ""
|
| 1289 |
user_obj = current_user_state
|
| 1290 |
|
| 1291 |
-
|
| 1292 |
-
chat_history.append({"role": "user", "content": user_message})
|
| 1293 |
-
chat_history.append({"role": "MateAI", "content": "¡Che, para arrancar, necesito que crees o cargues tu perfil en la sección 'Inicio & Perfil'! Después volvé acá y seguimos charlando."})
|
| 1294 |
-
return chat_history, "", conversation_context_state, "¡Che, para arrancar, necesito que crees o cargues tu perfil en la sección 'Inicio & Perfil'! Después volvé acá y seguimos charlando.", gr.skip(), gr.skip(), gr.skip()
|
| 1295 |
-
|
| 1296 |
-
# Append user message to chat history
|
| 1297 |
chat_history.append({"role": "user", "content": user_message})
|
| 1298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1299 |
# Command handling for other sections (simulates voice controlling the menu)
|
| 1300 |
if "oráculo" in user_message_lower or "revelación" in user_message_lower:
|
| 1301 |
revelation_text = await nudge_generator.get_daily_oracle_revelation(user_obj.user_id)
|
|
@@ -1381,17 +1382,17 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1381 |
sentiment = conversation_context_state["sentiment"]
|
| 1382 |
pending_nudge_request = conversation_context_state["pending_nudge_request"]
|
| 1383 |
|
| 1384 |
-
if "susurro" in user_message_lower or "decime algo" in user_message_lower or "onda" in user_message_lower or "che" in user_message_lower:
|
| 1385 |
pending_nudge_request = True
|
| 1386 |
conversation_context_state["pending_nudge_request"] = True
|
| 1387 |
if not location:
|
| 1388 |
-
response = "¡Dale! Para cebarte un susurro a medida, contame, ¿dónde estás ahora? ¿En casa, en la oficina, en la calle?"
|
| 1389 |
conversation_context_state["step"] = "ask_location"
|
| 1390 |
elif not activity:
|
| 1391 |
-
response = f"Ah, estás en {location}. ¿Y en qué andás ahora? ¿Laburando, haciendo ejercicio, relajado, cocinando, viendo un partido?"
|
| 1392 |
conversation_context_state["step"] = "ask_activity"
|
| 1393 |
elif not sentiment:
|
| 1394 |
-
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado?"
|
| 1395 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1396 |
else:
|
| 1397 |
# We have everything, generate the nudge
|
|
@@ -1410,16 +1411,16 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1410 |
elif any(k in user_message_lower for k in ["calle", "aire libre", "plaza", "parque", "caminando"]):
|
| 1411 |
location = "Aire Libre/Calle"
|
| 1412 |
else:
|
| 1413 |
-
response = "No te entendí bien, che. ¿Estás en casa, en la oficina o en la calle?"
|
| 1414 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1415 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1416 |
|
| 1417 |
conversation_context_state["location"] = location
|
| 1418 |
if not activity:
|
| 1419 |
-
response = f"Ah, estás en {location}. ¿Y en qué andás ahora? ¿Laburando, haciendo ejercicio, relajado, cocinando, viendo un partido?"
|
| 1420 |
conversation_context_state["step"] = "ask_activity"
|
| 1421 |
elif not sentiment:
|
| 1422 |
-
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado?"
|
| 1423 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1424 |
else: # Should not happen if flow is sequential, but as fallback
|
| 1425 |
nudge_text, current_points, current_insignia, next_insignia_goal, historial = await nudge_generator.generate_nudge(user_obj.user_id, location, activity, sentiment)
|
|
@@ -1442,13 +1443,13 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1442 |
elif any(k in user_message_lower for k in ["partido", "fútbol", "viendo tele"]):
|
| 1443 |
activity = "Viendo un partido"
|
| 1444 |
else:
|
| 1445 |
-
response = "No te pesqué esa, che. ¿Estás laburando, haciendo ejercicio, relajado, cocinando, o viendo un partido?"
|
| 1446 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1447 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1448 |
|
| 1449 |
conversation_context_state["activity"] = activity
|
| 1450 |
if not sentiment:
|
| 1451 |
-
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado?"
|
| 1452 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1453 |
else: # Should not happen if flow is sequential, but as fallback
|
| 1454 |
nudge_text, current_points, current_insignia, next_insignia_goal, historial = await nudge_generator.generate_nudge(user_obj.user_id, location, activity, sentiment)
|
|
@@ -1467,7 +1468,7 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1467 |
elif any(k in user_message_lower for k in ["motivado", "con pilas", "enchufado"]):
|
| 1468 |
sentiment = "Motivado"
|
| 1469 |
else:
|
| 1470 |
-
response = "No te capto el sentimiento, che. ¿Estás bien, cansado, bajoneado o motivado?"
|
| 1471 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1472 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1473 |
|
|
@@ -1481,7 +1482,7 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1481 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1482 |
|
| 1483 |
else: # Default response if no specific command or context step
|
| 1484 |
-
response = "¡No te entendí bien, che! Soy MateAI, tu compañero. Si querés un susurro, decime 'quiero un susurro' y te voy a preguntar unas cositas. Si no, decime qué andás necesitando."
|
| 1485 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1486 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1487 |
|
|
@@ -1569,7 +1570,7 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1569 |
fn=change_view,
|
| 1570 |
inputs=[hidden_view_input],
|
| 1571 |
outputs=[
|
| 1572 |
-
home_section,
|
| 1573 |
challenges_section, history_section, tasks_section,
|
| 1574 |
browser_agent_section, current_view_state
|
| 1575 |
]
|
|
@@ -1577,3 +1578,4 @@ with demo: # Ahora el bloque 'with' utiliza el objeto demo ya creado
|
|
| 1577 |
|
| 1578 |
# Lanza la interfaz de Gradio
|
| 1579 |
demo.launch()
|
|
|
|
|
|
| 27 |
# La configuración de Firebase se cargará desde la variable de entorno __firebase_config
|
| 28 |
# o se usará la configuración proporcionada por el usuario si no está definida.
|
| 29 |
# En un entorno de producción real, se recomienda usar variables de entorno seguras.
|
| 30 |
+
# El project_id es mateai-815ca, como se especificó.
|
| 31 |
+
FIREBASE_COLLECTION_USERS = "artifacts/mateai-815ca/users" # Colección para datos de usuario
|
| 32 |
|
| 33 |
# --- Firebase Initialization ---
|
| 34 |
# Intenta inicializar Firebase Admin SDK.
|
|
|
|
| 206 |
Nudge("Antes de seguir con el laburo, ¿ya almorzaste, {user_name}? Una buena comida te da la nafta para seguir.", "bienestar", ["Mediodía/Tarde", "Oficina/Estudio", "Trabajando"], ["almuerzo", "energia"]),
|
| 207 |
|
| 208 |
# Mediodía/Tarde - Aire Libre/Calle
|
| 209 |
+
Nudge("El solcito de la tarde es ideal para recargar pilas, {user_name}. ¡Disfrutá el momento! El {clima_actual} es ideal.", "bienestar", ["Mediodía/Tarde", "Aire Libre/Calle"], ["sol", "energia"]),
|
| 210 |
Nudge("Mirá las nubes, ¿qué formas ves? La imaginación vuela libre, {user_name}.", "bienestar", ["Mediodía/Tarde", "Aire Libre/Calle"], ["nubes", "imaginacion"]),
|
| 211 |
Nudge("Si encontrás un banquito, sentate un rato, {user_name}. Observá la gente, la vida que pasa. ¡Es un 'recreo' para el alma!", "bienestar", ["Mediodía/Tarde", "Aire Libre/Calle"], ["pausa", "observacion"]),
|
| 212 |
|
|
|
|
| 753 |
<script>
|
| 754 |
let recognition;
|
| 755 |
let speaking = false;
|
| 756 |
+
let lastSpokenText = ""; // To prevent repeating the same spoken text
|
| 757 |
const matecitoAvatar = document.getElementById('matecito_avatar');
|
| 758 |
const voiceStatus = document.getElementById('voice_status');
|
| 759 |
const startVoiceButton = document.getElementById('start_voice_button'); // Get the button element
|
|
|
|
| 961 |
)
|
| 962 |
|
| 963 |
# --- Contenido de cada Sección (Ahora en gr.Group o gr.Column) ---
|
| 964 |
+
# Todas las secciones deben ser definidas aquí para poder ser referenciadas en los outputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 965 |
home_section = gr.Column(elem_id="home_section", elem_classes="section-content", visible=True)
|
| 966 |
+
nudges_section = gr.Column(elem_id="nudges_section", elem_classes="section-content", visible=False)
|
| 967 |
oracle_section = gr.Column(elem_id="oracle_section", elem_classes="section-content", visible=False)
|
| 968 |
challenges_section = gr.Column(elem_id="challenges_section", elem_classes="section-content", visible=False)
|
|
|
|
| 969 |
tasks_section = gr.Column(elem_id="tasks_section", elem_classes="section-content", visible=False)
|
| 970 |
+
history_section = gr.Column(elem_id="history_section", elem_classes="section-content", visible=False)
|
| 971 |
browser_agent_section = gr.Column(elem_id="browser_agent_section", elem_classes="section-content", visible=False)
|
|
|
|
| 972 |
|
| 973 |
with home_section: # Home visible por defecto
|
| 974 |
+
gr.Markdown("<h2 style='color: #10b981;'>¡Bienvenido a tu Espacio MateAI!</h2><p>Acá manejás tu perfil para que MateAI te conozca a fondo y te ofrezca una experiencia bien personalizada.</p>")
|
| 975 |
with gr.Row():
|
| 976 |
with gr.Column():
|
| 977 |
gr.Markdown("<h3 style='color: #38bdf8;'>Crear Nuevo Usuario</h3>")
|
|
|
|
| 1009 |
label="Frecuencia de susurros",
|
| 1010 |
value="normal"
|
| 1011 |
)
|
| 1012 |
+
modo_che_tranqui_checkbox = gr.Checkbox(label="Activar 'Modo Che, Tranqui' (prioriza calma y reflexión en los susurros)", value=False)
|
| 1013 |
|
| 1014 |
btn_actualizar_preferencias = gr.Button("Actualizar Preferencias", variant="primary")
|
| 1015 |
output_actualizar_preferencias = gr.Textbox(label="Estado de Actualización", interactive=False)
|
| 1016 |
|
| 1017 |
+
with nudges_section: # Nudges visible por defecto
|
| 1018 |
+
gr.Markdown("<h2 style='color: #10b981;'>¡Che, acá estoy para cebarte un susurro!</h2><p>Contame un poco de tu día y te tiro la posta. Para empezar, podés decir: <b>'Quiero un susurro'</b>.</p>")
|
| 1019 |
+
chat_history = gr.State([]) # Para mantener el historial del chat
|
| 1020 |
+
chatbot = gr.Chatbot(label="Conversación con MateAI", height=300, type='messages') # Added type='messages'
|
| 1021 |
+
msg_input = gr.Textbox(label="Contale a MateAI...", placeholder="Ej: 'Estoy en casa, laburando y medio cansado.' o 'Quiero un susurro de bienestar.'")
|
| 1022 |
+
|
| 1023 |
+
# Botón para enviar el mensaje de texto (además de la entrada de voz)
|
| 1024 |
+
btn_send_msg = gr.Button("Enviar Mensaje", variant="primary")
|
| 1025 |
+
|
| 1026 |
with oracle_section:
|
| 1027 |
gr.Markdown("<h2 style='text-align: center; color: #10b981;'>✨ La Revelación Diaria del Oráculo MateAI ✨</h2><p style='text-align: center;'>Una sabiduría profunda para iluminar tu jornada. El Oráculo te habla una vez al día.</p>")
|
| 1028 |
oraculo_output = gr.Textbox(
|
|
|
|
| 1146 |
# Create a dictionary to hold updates for each section
|
| 1147 |
updates = {
|
| 1148 |
"home_section": gr.Column.update(visible=False),
|
|
|
|
| 1149 |
"nudges_section": gr.Column.update(visible=False),
|
| 1150 |
+
"oracle_section": gr.Column.update(visible=False),
|
| 1151 |
"challenges_section": gr.Column.update(visible=False),
|
| 1152 |
"history_section": gr.Column.update(visible=False),
|
| 1153 |
"tasks_section": gr.Column.update(visible=False),
|
|
|
|
| 1159 |
# Return the updates in a consistent order, followed by the state update
|
| 1160 |
return (
|
| 1161 |
updates["home_section"],
|
|
|
|
| 1162 |
updates["nudges_section"],
|
| 1163 |
+
updates["oracle_section"],
|
| 1164 |
updates["challenges_section"],
|
| 1165 |
updates["history_section"],
|
| 1166 |
updates["tasks_section"],
|
|
|
|
| 1288 |
response = ""
|
| 1289 |
user_obj = current_user_state
|
| 1290 |
|
| 1291 |
+
# Append user message to chat history immediately
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1292 |
chat_history.append({"role": "user", "content": user_message})
|
| 1293 |
|
| 1294 |
+
# Check if user is logged in
|
| 1295 |
+
if not user_obj:
|
| 1296 |
+
mateai_response = "¡Che, para arrancar, necesito que crees o cargues tu perfil en la sección 'Inicio & Perfil'! Después volvé acá y seguimos charlando."
|
| 1297 |
+
chat_history.append({"role": "MateAI", "content": mateai_response})
|
| 1298 |
+
return chat_history, "", conversation_context_state, mateai_response, gr.skip(), gr.skip(), gr.skip()
|
| 1299 |
+
|
| 1300 |
# Command handling for other sections (simulates voice controlling the menu)
|
| 1301 |
if "oráculo" in user_message_lower or "revelación" in user_message_lower:
|
| 1302 |
revelation_text = await nudge_generator.get_daily_oracle_revelation(user_obj.user_id)
|
|
|
|
| 1382 |
sentiment = conversation_context_state["sentiment"]
|
| 1383 |
pending_nudge_request = conversation_context_state["pending_nudge_request"]
|
| 1384 |
|
| 1385 |
+
if "susurro" in user_message_lower or "decime algo" in user_message_lower or "onda" in user_message_lower or "che" in user_message_lower or pending_nudge_request:
|
| 1386 |
pending_nudge_request = True
|
| 1387 |
conversation_context_state["pending_nudge_request"] = True
|
| 1388 |
if not location:
|
| 1389 |
+
response = "¡Dale! Para cebarte un susurro a medida, contame, ¿dónde estás ahora? ¿En casa, en la oficina, en la calle? (Ej: 'Estoy en casa')"
|
| 1390 |
conversation_context_state["step"] = "ask_location"
|
| 1391 |
elif not activity:
|
| 1392 |
+
response = f"Ah, estás en {location}. ¿Y en qué andás ahora? ¿Laburando, haciendo ejercicio, relajado, cocinando, viendo un partido? (Ej: 'Estoy laburando')"
|
| 1393 |
conversation_context_state["step"] = "ask_activity"
|
| 1394 |
elif not sentiment:
|
| 1395 |
+
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado? (Ej: 'Me siento bien')"
|
| 1396 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1397 |
else:
|
| 1398 |
# We have everything, generate the nudge
|
|
|
|
| 1411 |
elif any(k in user_message_lower for k in ["calle", "aire libre", "plaza", "parque", "caminando"]):
|
| 1412 |
location = "Aire Libre/Calle"
|
| 1413 |
else:
|
| 1414 |
+
response = "No te entendí bien, che. ¿Estás en casa, en la oficina o en la calle? (Ej: 'Estoy en casa')"
|
| 1415 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1416 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1417 |
|
| 1418 |
conversation_context_state["location"] = location
|
| 1419 |
if not activity:
|
| 1420 |
+
response = f"Ah, estás en {location}. ¿Y en qué andás ahora? ¿Laburando, haciendo ejercicio, relajado, cocinando, viendo un partido? (Ej: 'Estoy laburando')"
|
| 1421 |
conversation_context_state["step"] = "ask_activity"
|
| 1422 |
elif not sentiment:
|
| 1423 |
+
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado? (Ej: 'Me siento bien')"
|
| 1424 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1425 |
else: # Should not happen if flow is sequential, but as fallback
|
| 1426 |
nudge_text, current_points, current_insignia, next_insignia_goal, historial = await nudge_generator.generate_nudge(user_obj.user_id, location, activity, sentiment)
|
|
|
|
| 1443 |
elif any(k in user_message_lower for k in ["partido", "fútbol", "viendo tele"]):
|
| 1444 |
activity = "Viendo un partido"
|
| 1445 |
else:
|
| 1446 |
+
response = "No te pesqué esa, che. ¿Estás laburando, haciendo ejercicio, relajado, cocinando, o viendo un partido? (Ej: 'Estoy relajado')"
|
| 1447 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1448 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1449 |
|
| 1450 |
conversation_context_state["activity"] = activity
|
| 1451 |
if not sentiment:
|
| 1452 |
+
response = f"Entendido, en {location} y {activity}. ¿Y cómo te sentís? ¿Bien, cansado, bajoneado, motivado? (Ej: 'Me siento bien')"
|
| 1453 |
conversation_context_state["step"] = "ask_sentiment"
|
| 1454 |
else: # Should not happen if flow is sequential, but as fallback
|
| 1455 |
nudge_text, current_points, current_insignia, next_insignia_goal, historial = await nudge_generator.generate_nudge(user_obj.user_id, location, activity, sentiment)
|
|
|
|
| 1468 |
elif any(k in user_message_lower for k in ["motivado", "con pilas", "enchufado"]):
|
| 1469 |
sentiment = "Motivado"
|
| 1470 |
else:
|
| 1471 |
+
response = "No te capto el sentimiento, che. ¿Estás bien, cansado, bajoneado o motivado? (Ej: 'Estoy cansado')"
|
| 1472 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1473 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1474 |
|
|
|
|
| 1482 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1483 |
|
| 1484 |
else: # Default response if no specific command or context step
|
| 1485 |
+
response = "¡No te entendí bien, che! Soy MateAI, tu compañero. Si querés un susurro, decime <b>'quiero un susurro'</b> y te voy a preguntar unas cositas. Si no, decime qué andás necesitando."
|
| 1486 |
chat_history.append({"role": "MateAI", "content": response})
|
| 1487 |
return chat_history, "", conversation_context_state, response, gr.skip(), gr.skip(), gr.skip()
|
| 1488 |
|
|
|
|
| 1570 |
fn=change_view,
|
| 1571 |
inputs=[hidden_view_input],
|
| 1572 |
outputs=[
|
| 1573 |
+
home_section, nudges_section, oracle_section,
|
| 1574 |
challenges_section, history_section, tasks_section,
|
| 1575 |
browser_agent_section, current_view_state
|
| 1576 |
]
|
|
|
|
| 1578 |
|
| 1579 |
# Lanza la interfaz de Gradio
|
| 1580 |
demo.launch()
|
| 1581 |
+
�
|