Jeremy Live commited on
Commit
22e000d
1 Parent(s): 59097a1

Revert "fix repond text memoria grafica v1"

Browse files

This reverts commit 59097a1e696d24228ac6b10723111b57ba93c139.

Files changed (1) hide show
  1. app.py +1 -36
app.py CHANGED
@@ -1004,20 +1004,7 @@ def create_application():
1004
  title=chart_state_value.get("title", "Distribuci贸n")
1005
  )
1006
  if fig is not None:
1007
- # Professional, context-aware response for chart regeneration
1008
- chart_types = {
1009
- 'bar': 'gr谩fico de barras',
1010
- 'line': 'gr谩fico de l铆neas',
1011
- 'pie': 'gr谩fico circular',
1012
- 'scatter': 'gr谩fico de dispersi贸n',
1013
- 'histogram': 'histograma'
1014
- }
1015
- chart_name = chart_types.get(new_type, f"gr谩fico de tipo '{new_type}'")
1016
-
1017
- friendly = (
1018
- f"He generado un {chart_name} con los datos de la consulta anterior. "
1019
- f"Si deseas otro tipo de visualizaci贸n, filtrar o segmentar la informaci贸n, ind铆calo."
1020
- )
1021
  chat_history.append({"role": "assistant", "content": friendly})
1022
  # Save new type in state
1023
  chart_state_value = {
@@ -1046,28 +1033,6 @@ def create_application():
1046
  # Call the agent for this new user question
1047
  assistant_message, chart_fig, new_state = await stream_agent_response(question, pair_history)
1048
 
1049
- # If the agent returned a generic lack-of-context message but we did generate a chart
1050
- # or we have state to satisfy the intent, replace with a professional, context-aware reply.
1051
- low_ctx_markers = [
1052
- "i don't have enough information",
1053
- "please provide more context",
1054
- "necesito m谩s informaci贸n",
1055
- "no tengo suficiente informaci贸n",
1056
- ]
1057
- msg_lower = (assistant_message or "").lower()
1058
- if any(m in msg_lower for m in low_ctx_markers) and (chart_fig is not None or new_state):
1059
- # Choose type from new_state or fallback to bar
1060
- t = None
1061
- if isinstance(new_state, dict):
1062
- t = new_state.get("chart_type")
1063
- if not t and chart_state_value and isinstance(chart_state_value, dict):
1064
- t = chart_state_value.get("chart_type")
1065
- tipo = ("gr谩fico circular" if t == "pie" else (f"gr谩fico de {t}" if t else "gr谩fico"))
1066
- assistant_message = (
1067
- f"He generado la visualizaci贸n solicitada. A continuaci贸n muestro un {tipo} basado en tu petici贸n. "
1068
- f"Si necesitas ajustar el tipo de gr谩fico, el rango de datos o aplicar filtros adicionales, ind铆calo."
1069
- )
1070
-
1071
  # Append assistant message back into messages history
1072
  chat_history.append({"role": "assistant", "content": assistant_message})
1073
 
 
1004
  title=chart_state_value.get("title", "Distribuci贸n")
1005
  )
1006
  if fig is not None:
1007
+ friendly = f"He actualizado la visualizaci贸n a {('gr谩fico de ' + new_type) if new_type != 'pie' else 'gr谩fico circular'} usando los mismos datos."
 
 
 
 
 
 
 
 
 
 
 
 
 
1008
  chat_history.append({"role": "assistant", "content": friendly})
1009
  # Save new type in state
1010
  chart_state_value = {
 
1033
  # Call the agent for this new user question
1034
  assistant_message, chart_fig, new_state = await stream_agent_response(question, pair_history)
1035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1036
  # Append assistant message back into messages history
1037
  chat_history.append({"role": "assistant", "content": assistant_message})
1038