Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,57 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
import json
|
|
|
|
|
|
|
| 4 |
from chatbot_nuti import buscar_respuesta
|
| 5 |
from coach_emocional import coach_emocional_inteligente
|
| 6 |
from retos_saludables import mostrar_retos, completar_reto
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
estado_app = {
|
| 11 |
"memoria_nuti": [],
|
| 12 |
"memoria_coach": [],
|
| 13 |
"calorias_totales": 0,
|
| 14 |
-
"calorias_restantes": 0
|
| 15 |
-
"historial_comidas": [],
|
| 16 |
-
"recetas": []
|
| 17 |
}
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# ---------- CHATBOT NUTI ---------- #
|
| 21 |
def conversar_nuti(mensaje, historial):
|
| 22 |
-
if not mensaje.strip():
|
| 23 |
return historial, ""
|
| 24 |
|
| 25 |
-
estado_app["memoria_nuti"].append({"user": mensaje})
|
| 26 |
-
|
| 27 |
if historial is None:
|
| 28 |
historial = []
|
| 29 |
|
|
|
|
| 30 |
historial.append({"role": "user", "content": mensaje})
|
| 31 |
|
| 32 |
respuesta = buscar_respuesta(mensaje, estado_app["memoria_nuti"])
|
|
@@ -38,14 +63,13 @@ def conversar_nuti(mensaje, historial):
|
|
| 38 |
|
| 39 |
# ---------- COACH EMOCIONAL ---------- #
|
| 40 |
def conversar_coach(mensaje, historial):
|
| 41 |
-
if not mensaje.strip():
|
| 42 |
return historial, ""
|
| 43 |
|
| 44 |
-
estado_app["memoria_coach"].append({"user": mensaje})
|
| 45 |
-
|
| 46 |
if historial is None:
|
| 47 |
historial = []
|
| 48 |
|
|
|
|
| 49 |
historial.append({"role": "user", "content": mensaje})
|
| 50 |
|
| 51 |
respuesta = coach_emocional_inteligente(mensaje, estado_app["memoria_coach"])
|
|
@@ -91,6 +115,34 @@ def calcular_calorias(edad, peso, altura, genero, actividad, meta):
|
|
| 91 |
)
|
| 92 |
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
# ---------- CALORÍAS DEL RELOJ ---------- #
|
| 95 |
def calorias_reloj(calorias_quemadas):
|
| 96 |
if calorias_quemadas is None:
|
|
@@ -133,11 +185,20 @@ def registrar_comida(imagen):
|
|
| 133 |
estado_app["calorias_restantes"] -= calorias
|
| 134 |
estado_app["calorias_restantes"] = max(estado_app["calorias_restantes"], 0)
|
| 135 |
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
"comida": info,
|
| 138 |
"calorias": calorias
|
| 139 |
})
|
| 140 |
|
|
|
|
|
|
|
| 141 |
return (
|
| 142 |
f"{info}\n\n"
|
| 143 |
f"🔥 Calorías restantes del día: **{estado_app['calorias_restantes']} kcal**."
|
|
@@ -145,11 +206,15 @@ def registrar_comida(imagen):
|
|
| 145 |
|
| 146 |
|
| 147 |
def mostrar_historial():
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
return "📭 Aún no has registrado comidas hoy."
|
| 150 |
|
| 151 |
texto = "🍴 **Historial de comidas:**\n\n"
|
| 152 |
-
for i, item in enumerate(
|
| 153 |
texto += f"{i}. {item['comida']}\n"
|
| 154 |
|
| 155 |
texto += f"\n🔥 Te quedan **{estado_app['calorias_restantes']} kcal** por consumir hoy."
|
|
@@ -158,23 +223,28 @@ def mostrar_historial():
|
|
| 158 |
|
| 159 |
# ---------- RECETAS ---------- #
|
| 160 |
def subir_receta(nombre, descripcion, imagen):
|
| 161 |
-
if nombre
|
| 162 |
-
|
| 163 |
-
"nombre": nombre,
|
| 164 |
-
"descripcion": descripcion,
|
| 165 |
-
"imagen": imagen
|
| 166 |
-
})
|
| 167 |
-
return f"✅ Receta '{nombre}' añadida correctamente."
|
| 168 |
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
def mostrar_recetas():
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
return "📭 No hay recetas cargadas aún."
|
| 175 |
|
| 176 |
texto = "🍽️ **Recetas Recomendadas:**\n\n"
|
| 177 |
-
for receta in
|
| 178 |
texto += f"**{receta['nombre']}**\n{receta['descripcion']}\n\n"
|
| 179 |
|
| 180 |
return texto
|
|
@@ -238,40 +308,35 @@ def buscar_nutriologos(pais, estado, ciudad):
|
|
| 238 |
return texto
|
| 239 |
|
| 240 |
|
| 241 |
-
# ----------
|
| 242 |
-
def
|
| 243 |
-
perfil = {
|
| 244 |
-
|
| 245 |
-
"
|
| 246 |
-
"peso": peso,
|
| 247 |
-
"altura": altura,
|
| 248 |
-
"genero": genero,
|
| 249 |
-
"actividad": actividad,
|
| 250 |
-
"meta": meta,
|
| 251 |
-
"condicion": condicion,
|
| 252 |
-
"alergias": alergias
|
| 253 |
-
}
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
-
|
| 259 |
-
f"
|
|
|
|
|
|
|
|
|
|
| 260 |
f"**Condición:** {condicion or 'ninguna'}\n"
|
| 261 |
-
f"**Alergias:** {alergias or 'ninguna'}"
|
|
|
|
|
|
|
| 262 |
)
|
| 263 |
|
| 264 |
-
mensaje_calorias = calcular_calorias(edad, peso, altura, genero, actividad, meta)
|
| 265 |
-
|
| 266 |
-
return f"{mensaje_guardado}\n\n{mensaje_calorias}"
|
| 267 |
-
|
| 268 |
|
| 269 |
# ---------- INTERFAZ PRINCIPAL ---------- #
|
| 270 |
with gr.Blocks(title="NutriBot IA 🥗") as app:
|
| 271 |
gr.Markdown("# 🧠 Bienvenido a **NutriBot IA** 🍎")
|
| 272 |
gr.Markdown("Comer sano, inteligente y divertido. 🌿")
|
| 273 |
|
| 274 |
-
# --- DATOS PERSONALES --- #
|
| 275 |
with gr.Tab("👤 Datos Personales"):
|
| 276 |
with gr.Row():
|
| 277 |
nombre = gr.Textbox(label="Nombre completo")
|
|
@@ -308,7 +373,10 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 308 |
outputs=salida_datos
|
| 309 |
)
|
| 310 |
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
| 312 |
with gr.Tab("📸 Registro de Comidas"):
|
| 313 |
gr.Markdown("Sube una foto de tu comida y NutriBot estimará las calorías 🍽️")
|
| 314 |
imagen = gr.Image(label="Foto de tu comida", type="filepath")
|
|
@@ -321,14 +389,12 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 321 |
salida_historial = gr.Markdown()
|
| 322 |
boton_historial.click(mostrar_historial, outputs=salida_historial)
|
| 323 |
|
| 324 |
-
# --- CALORÍAS DEL RELOJ --- #
|
| 325 |
with gr.Tab("⌚ Calorías del Reloj"):
|
| 326 |
calorias_quemadas = gr.Number(label="Calorías quemadas (reloj inteligente)")
|
| 327 |
boton_reloj = gr.Button("Actualizar 🔁")
|
| 328 |
salida_reloj = gr.Markdown()
|
| 329 |
boton_reloj.click(calorias_reloj, inputs=calorias_quemadas, outputs=salida_reloj)
|
| 330 |
|
| 331 |
-
# --- CHAT NUTI --- #
|
| 332 |
with gr.Tab("🤖 Chat con Nuti"):
|
| 333 |
chat_nuti = gr.Chatbot(label="Nuti - Tu guía de nutrición 🍎", type="messages")
|
| 334 |
entrada_nuti = gr.Textbox(label="Escribe algo para Nuti...")
|
|
@@ -339,7 +405,6 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 339 |
outputs=[chat_nuti, entrada_nuti]
|
| 340 |
)
|
| 341 |
|
| 342 |
-
# --- COACH EMOCIONAL --- #
|
| 343 |
with gr.Tab("🧘 Coach Emocional"):
|
| 344 |
chat_coach = gr.Chatbot(label="Coach Emocional 🌿", type="messages")
|
| 345 |
entrada_coach = gr.Textbox(label="Cuéntame cómo te sientes hoy...")
|
|
@@ -350,11 +415,10 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 350 |
outputs=[chat_coach, entrada_coach]
|
| 351 |
)
|
| 352 |
|
| 353 |
-
# --- RECETAS --- #
|
| 354 |
with gr.Tab("🍽️ Recetas del Nutriólogo"):
|
| 355 |
nombre_rec = gr.Textbox(label="Nombre de la receta")
|
| 356 |
descripcion = gr.Textbox(label="Descripción o ingredientes")
|
| 357 |
-
imagen_receta = gr.Image(label="Imagen (opcional)")
|
| 358 |
boton_subir = gr.Button("Subir receta")
|
| 359 |
salida_subir = gr.Textbox(label="Estado")
|
| 360 |
boton_subir.click(
|
|
@@ -367,7 +431,6 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 367 |
salida_recetas = gr.Markdown()
|
| 368 |
boton_ver.click(mostrar_recetas, outputs=salida_recetas)
|
| 369 |
|
| 370 |
-
# --- RETOS --- #
|
| 371 |
with gr.Tab("🎯 Retos Saludables"):
|
| 372 |
salida_retos = gr.Markdown()
|
| 373 |
|
|
@@ -378,7 +441,6 @@ with gr.Blocks(title="NutriBot IA 🥗") as app:
|
|
| 378 |
boton_completar = gr.Button("Completar Reto 🏅")
|
| 379 |
boton_completar.click(completar_reto, inputs=numero_reto, outputs=salida_retos)
|
| 380 |
|
| 381 |
-
# --- NUTRIÓLOGOS --- #
|
| 382 |
with gr.Tab("🧑⚕️ Buscar Nutriólogos"):
|
| 383 |
pais = gr.Textbox(label="País")
|
| 384 |
estado = gr.Textbox(label="Estado")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
import json
|
| 4 |
+
import os
|
| 5 |
+
from datetime import datetime
|
| 6 |
from chatbot_nuti import buscar_respuesta
|
| 7 |
from coach_emocional import coach_emocional_inteligente
|
| 8 |
from retos_saludables import mostrar_retos, completar_reto
|
| 9 |
|
| 10 |
+
PERFIL_FILE = "perfil_usuario.json"
|
| 11 |
+
COMIDAS_FILE = "historial_comidas.json"
|
| 12 |
+
RECETAS_FILE = "recetas_nutribot.json"
|
| 13 |
|
| 14 |
+
|
| 15 |
+
# ---------- ESTADO SIMPLE EN MEMORIA ---------- #
|
| 16 |
estado_app = {
|
| 17 |
"memoria_nuti": [],
|
| 18 |
"memoria_coach": [],
|
| 19 |
"calorias_totales": 0,
|
| 20 |
+
"calorias_restantes": 0
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
|
| 24 |
+
# ---------- UTILIDADES JSON ---------- #
|
| 25 |
+
def cargar_json(path, default):
|
| 26 |
+
if os.path.exists(path):
|
| 27 |
+
try:
|
| 28 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 29 |
+
return json.load(f)
|
| 30 |
+
except json.JSONDecodeError:
|
| 31 |
+
return default
|
| 32 |
+
return default
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def guardar_json(path, data):
|
| 36 |
+
with open(path, "w", encoding="utf-8") as f:
|
| 37 |
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def obtener_nombre_usuario():
|
| 41 |
+
perfil = cargar_json(PERFIL_FILE, {})
|
| 42 |
+
nombre = perfil.get("nombre", "Usuario")
|
| 43 |
+
return nombre.strip() if isinstance(nombre, str) and nombre.strip() else "Usuario"
|
| 44 |
+
|
| 45 |
+
|
| 46 |
# ---------- CHATBOT NUTI ---------- #
|
| 47 |
def conversar_nuti(mensaje, historial):
|
| 48 |
+
if not mensaje or not mensaje.strip():
|
| 49 |
return historial, ""
|
| 50 |
|
|
|
|
|
|
|
| 51 |
if historial is None:
|
| 52 |
historial = []
|
| 53 |
|
| 54 |
+
estado_app["memoria_nuti"].append({"user": mensaje})
|
| 55 |
historial.append({"role": "user", "content": mensaje})
|
| 56 |
|
| 57 |
respuesta = buscar_respuesta(mensaje, estado_app["memoria_nuti"])
|
|
|
|
| 63 |
|
| 64 |
# ---------- COACH EMOCIONAL ---------- #
|
| 65 |
def conversar_coach(mensaje, historial):
|
| 66 |
+
if not mensaje or not mensaje.strip():
|
| 67 |
return historial, ""
|
| 68 |
|
|
|
|
|
|
|
| 69 |
if historial is None:
|
| 70 |
historial = []
|
| 71 |
|
| 72 |
+
estado_app["memoria_coach"].append({"user": mensaje})
|
| 73 |
historial.append({"role": "user", "content": mensaje})
|
| 74 |
|
| 75 |
respuesta = coach_emocional_inteligente(mensaje, estado_app["memoria_coach"])
|
|
|
|
| 115 |
)
|
| 116 |
|
| 117 |
|
| 118 |
+
# ---------- GUARDAR DATOS ---------- #
|
| 119 |
+
def guardar_informacion(nombre, edad, peso, altura, genero, actividad, meta, condicion, alergias):
|
| 120 |
+
perfil = {
|
| 121 |
+
"nombre": nombre,
|
| 122 |
+
"edad": edad,
|
| 123 |
+
"peso": peso,
|
| 124 |
+
"altura": altura,
|
| 125 |
+
"genero": genero,
|
| 126 |
+
"actividad": actividad,
|
| 127 |
+
"meta": meta,
|
| 128 |
+
"condicion": condicion,
|
| 129 |
+
"alergias": alergias
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
guardar_json(PERFIL_FILE, perfil)
|
| 133 |
+
|
| 134 |
+
mensaje_guardado = (
|
| 135 |
+
f"✅ Información guardada.\n"
|
| 136 |
+
f"**Nombre:** {nombre or 'Sin nombre'}\n"
|
| 137 |
+
f"**Condición:** {condicion or 'ninguna'}\n"
|
| 138 |
+
f"**Alergias:** {alergias or 'ninguna'}"
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
mensaje_calorias = calcular_calorias(edad, peso, altura, genero, actividad, meta)
|
| 142 |
+
|
| 143 |
+
return f"{mensaje_guardado}\n\n{mensaje_calorias}"
|
| 144 |
+
|
| 145 |
+
|
| 146 |
# ---------- CALORÍAS DEL RELOJ ---------- #
|
| 147 |
def calorias_reloj(calorias_quemadas):
|
| 148 |
if calorias_quemadas is None:
|
|
|
|
| 185 |
estado_app["calorias_restantes"] -= calorias
|
| 186 |
estado_app["calorias_restantes"] = max(estado_app["calorias_restantes"], 0)
|
| 187 |
|
| 188 |
+
nombre_usuario = obtener_nombre_usuario()
|
| 189 |
+
datos = cargar_json(COMIDAS_FILE, {})
|
| 190 |
+
|
| 191 |
+
if nombre_usuario not in datos:
|
| 192 |
+
datos[nombre_usuario] = []
|
| 193 |
+
|
| 194 |
+
datos[nombre_usuario].append({
|
| 195 |
+
"fecha": str(datetime.now()),
|
| 196 |
"comida": info,
|
| 197 |
"calorias": calorias
|
| 198 |
})
|
| 199 |
|
| 200 |
+
guardar_json(COMIDAS_FILE, datos)
|
| 201 |
+
|
| 202 |
return (
|
| 203 |
f"{info}\n\n"
|
| 204 |
f"🔥 Calorías restantes del día: **{estado_app['calorias_restantes']} kcal**."
|
|
|
|
| 206 |
|
| 207 |
|
| 208 |
def mostrar_historial():
|
| 209 |
+
nombre_usuario = obtener_nombre_usuario()
|
| 210 |
+
datos = cargar_json(COMIDAS_FILE, {})
|
| 211 |
+
historial = datos.get(nombre_usuario, [])
|
| 212 |
+
|
| 213 |
+
if not historial:
|
| 214 |
return "📭 Aún no has registrado comidas hoy."
|
| 215 |
|
| 216 |
texto = "🍴 **Historial de comidas:**\n\n"
|
| 217 |
+
for i, item in enumerate(historial[-10:], 1):
|
| 218 |
texto += f"{i}. {item['comida']}\n"
|
| 219 |
|
| 220 |
texto += f"\n🔥 Te quedan **{estado_app['calorias_restantes']} kcal** por consumir hoy."
|
|
|
|
| 223 |
|
| 224 |
# ---------- RECETAS ---------- #
|
| 225 |
def subir_receta(nombre, descripcion, imagen):
|
| 226 |
+
if not nombre or not descripcion:
|
| 227 |
+
return "⚠️ Ingresa nombre y descripción."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
+
datos = cargar_json(RECETAS_FILE, [])
|
| 230 |
+
datos.append({
|
| 231 |
+
"nombre": nombre,
|
| 232 |
+
"descripcion": descripcion,
|
| 233 |
+
"imagen": str(imagen) if imagen is not None else None
|
| 234 |
+
})
|
| 235 |
+
guardar_json(RECETAS_FILE, datos)
|
| 236 |
+
|
| 237 |
+
return f"✅ Receta '{nombre}' añadida correctamente."
|
| 238 |
|
| 239 |
|
| 240 |
def mostrar_recetas():
|
| 241 |
+
recetas = cargar_json(RECETAS_FILE, [])
|
| 242 |
+
|
| 243 |
+
if not recetas:
|
| 244 |
return "📭 No hay recetas cargadas aún."
|
| 245 |
|
| 246 |
texto = "🍽️ **Recetas Recomendadas:**\n\n"
|
| 247 |
+
for receta in recetas[-10:]:
|
| 248 |
texto += f"**{receta['nombre']}**\n{receta['descripcion']}\n\n"
|
| 249 |
|
| 250 |
return texto
|
|
|
|
| 308 |
return texto
|
| 309 |
|
| 310 |
|
| 311 |
+
# ---------- RESUMEN DEL USUARIO ---------- #
|
| 312 |
+
def ver_resumen():
|
| 313 |
+
perfil = cargar_json(PERFIL_FILE, {})
|
| 314 |
+
if not perfil:
|
| 315 |
+
return "📭 Aún no has guardado tus datos personales."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
+
nombre = perfil.get("nombre", "Usuario")
|
| 318 |
+
meta = perfil.get("meta", "No definida")
|
| 319 |
+
actividad = perfil.get("actividad", "No definida")
|
| 320 |
+
condicion = perfil.get("condicion", "ninguna")
|
| 321 |
+
alergias = perfil.get("alergias", "ninguna")
|
| 322 |
|
| 323 |
+
return (
|
| 324 |
+
f"👤 **Resumen del usuario**\n\n"
|
| 325 |
+
f"**Nombre:** {nombre}\n"
|
| 326 |
+
f"**Meta:** {meta}\n"
|
| 327 |
+
f"**Actividad:** {actividad}\n"
|
| 328 |
f"**Condición:** {condicion or 'ninguna'}\n"
|
| 329 |
+
f"**Alergias:** {alergias or 'ninguna'}\n"
|
| 330 |
+
f"**Calorías objetivo:** {estado_app['calorias_totales']} kcal\n"
|
| 331 |
+
f"**Calorías restantes:** {estado_app['calorias_restantes']} kcal"
|
| 332 |
)
|
| 333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
|
| 335 |
# ---------- INTERFAZ PRINCIPAL ---------- #
|
| 336 |
with gr.Blocks(title="NutriBot IA 🥗") as app:
|
| 337 |
gr.Markdown("# 🧠 Bienvenido a **NutriBot IA** 🍎")
|
| 338 |
gr.Markdown("Comer sano, inteligente y divertido. 🌿")
|
| 339 |
|
|
|
|
| 340 |
with gr.Tab("👤 Datos Personales"):
|
| 341 |
with gr.Row():
|
| 342 |
nombre = gr.Textbox(label="Nombre completo")
|
|
|
|
| 373 |
outputs=salida_datos
|
| 374 |
)
|
| 375 |
|
| 376 |
+
boton_resumen = gr.Button("Ver resumen 👀")
|
| 377 |
+
salida_resumen = gr.Markdown()
|
| 378 |
+
boton_resumen.click(ver_resumen, outputs=salida_resumen)
|
| 379 |
+
|
| 380 |
with gr.Tab("📸 Registro de Comidas"):
|
| 381 |
gr.Markdown("Sube una foto de tu comida y NutriBot estimará las calorías 🍽️")
|
| 382 |
imagen = gr.Image(label="Foto de tu comida", type="filepath")
|
|
|
|
| 389 |
salida_historial = gr.Markdown()
|
| 390 |
boton_historial.click(mostrar_historial, outputs=salida_historial)
|
| 391 |
|
|
|
|
| 392 |
with gr.Tab("⌚ Calorías del Reloj"):
|
| 393 |
calorias_quemadas = gr.Number(label="Calorías quemadas (reloj inteligente)")
|
| 394 |
boton_reloj = gr.Button("Actualizar 🔁")
|
| 395 |
salida_reloj = gr.Markdown()
|
| 396 |
boton_reloj.click(calorias_reloj, inputs=calorias_quemadas, outputs=salida_reloj)
|
| 397 |
|
|
|
|
| 398 |
with gr.Tab("🤖 Chat con Nuti"):
|
| 399 |
chat_nuti = gr.Chatbot(label="Nuti - Tu guía de nutrición 🍎", type="messages")
|
| 400 |
entrada_nuti = gr.Textbox(label="Escribe algo para Nuti...")
|
|
|
|
| 405 |
outputs=[chat_nuti, entrada_nuti]
|
| 406 |
)
|
| 407 |
|
|
|
|
| 408 |
with gr.Tab("🧘 Coach Emocional"):
|
| 409 |
chat_coach = gr.Chatbot(label="Coach Emocional 🌿", type="messages")
|
| 410 |
entrada_coach = gr.Textbox(label="Cuéntame cómo te sientes hoy...")
|
|
|
|
| 415 |
outputs=[chat_coach, entrada_coach]
|
| 416 |
)
|
| 417 |
|
|
|
|
| 418 |
with gr.Tab("🍽️ Recetas del Nutriólogo"):
|
| 419 |
nombre_rec = gr.Textbox(label="Nombre de la receta")
|
| 420 |
descripcion = gr.Textbox(label="Descripción o ingredientes")
|
| 421 |
+
imagen_receta = gr.Image(label="Imagen (opcional)", type="filepath")
|
| 422 |
boton_subir = gr.Button("Subir receta")
|
| 423 |
salida_subir = gr.Textbox(label="Estado")
|
| 424 |
boton_subir.click(
|
|
|
|
| 431 |
salida_recetas = gr.Markdown()
|
| 432 |
boton_ver.click(mostrar_recetas, outputs=salida_recetas)
|
| 433 |
|
|
|
|
| 434 |
with gr.Tab("🎯 Retos Saludables"):
|
| 435 |
salida_retos = gr.Markdown()
|
| 436 |
|
|
|
|
| 441 |
boton_completar = gr.Button("Completar Reto 🏅")
|
| 442 |
boton_completar.click(completar_reto, inputs=numero_reto, outputs=salida_retos)
|
| 443 |
|
|
|
|
| 444 |
with gr.Tab("🧑⚕️ Buscar Nutriólogos"):
|
| 445 |
pais = gr.Textbox(label="País")
|
| 446 |
estado = gr.Textbox(label="Estado")
|