adriansanz commited on
Commit
347733f
verified
1 Parent(s): 43a17a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -92,7 +92,7 @@ def predict_disponibilidad(context):
92
  context["month"],
93
  context["day"],
94
  context["hour"],
95
- 0.9, 0.9, 0.9, 0.9, # ctx hist贸ricos por defecto
96
  temp,
97
  precip
98
  ]])
@@ -242,6 +242,13 @@ with gr.Blocks() as demo:
242
  chatbot = gr.Chatbot()
243
  txt = gr.Textbox(placeholder="Escribe tu respuesta...", label="Tu mensaje")
244
 
 
 
 
 
 
 
 
245
  state_chat = gr.State([])
246
  state_step = gr.State(0)
247
  state_context = gr.State({
@@ -250,15 +257,22 @@ with gr.Blocks() as demo:
250
  "day": None,
251
  "hour": None,
252
  "target_pct": None,
 
253
  "temperature": None,
254
  "lluvia": None
255
  })
256
 
257
- def user_submit(message, chat_history, current_step, user_context):
 
 
 
258
  return chat(message, chat_history, current_step, user_context)
259
 
260
- txt.submit(user_submit, inputs=[txt, state_chat, state_step, state_context],
261
- outputs=[chatbot, state_step, state_context])
 
 
 
262
 
263
  # Primer mensaje
264
  primer_pregunta = preguntar_al_usuario(preguntas[0][1])
 
92
  context["month"],
93
  context["day"],
94
  context["hour"],
95
+ context["ctx_value"], context["ctx_value"], context["ctx_value"], context["ctx_value"],
96
  temp,
97
  precip
98
  ]])
 
242
  chatbot = gr.Chatbot()
243
  txt = gr.Textbox(placeholder="Escribe tu respuesta...", label="Tu mensaje")
244
 
245
+ # Nuevo input para ctx hist贸rico
246
+ ctx_selector = gr.Dropdown(
247
+ choices=["alto", "medio", "bajo"],
248
+ value="medio",
249
+ label="Nivel de ocupaci贸n hist贸rica (ctx)"
250
+ )
251
+
252
  state_chat = gr.State([])
253
  state_step = gr.State(0)
254
  state_context = gr.State({
 
257
  "day": None,
258
  "hour": None,
259
  "target_pct": None,
260
+ "ctx_value": 0.5, # valor por defecto
261
  "temperature": None,
262
  "lluvia": None
263
  })
264
 
265
+ def user_submit(message, chat_history, current_step, user_context, ctx_selector_value):
266
+ # Mapear valor textual a n煤mero
267
+ ctx_map = {"alto": 0.9, "medio": 0.5, "bajo": 0.1}
268
+ user_context["ctx_value"] = ctx_map.get(ctx_selector_value, 0.5)
269
  return chat(message, chat_history, current_step, user_context)
270
 
271
+ txt.submit(
272
+ user_submit,
273
+ inputs=[txt, state_chat, state_step, state_context, ctx_selector],
274
+ outputs=[chatbot, state_step, state_context]
275
+ )
276
 
277
  # Primer mensaje
278
  primer_pregunta = preguntar_al_usuario(preguntas[0][1])