pmelnechuk commited on
Commit
9fe87e6
·
verified ·
1 Parent(s): a0547b1

Prueba con interfaz sencilla

Browse files
Files changed (1) hide show
  1. app.py +6 -95
app.py CHANGED
@@ -59,101 +59,12 @@ if __name__=="__main__":
59
  # Carga del modelo y ejecución de la interfaz
60
  qa_chain=src.model_load.load_model()
61
  print("Lanzando interfaz")
62
- # Configuración de la página
63
- st.set_page_config(
64
- page_title="MathQA - Asistente de Matemáticas",
65
- page_icon="🧮",
66
- layout="centered",
67
- initial_sidebar_state="expanded"
68
- )
69
-
70
- # Paleta de colores neutra
71
- primary_color = "#010001"
72
- secondary_color = "#E7E6E7"
73
- background_color = "#FBFBFA"
74
-
75
- # Estilos CSS
76
- st.markdown(
77
- f"""
78
- <style>
79
- .stApp {{ background-color: {background_color}; }}
80
- .stTextInput>div>div>input {{
81
- color: {primary_color};
82
- background-color: {secondary_color};
83
- border-radius: 8px;
84
- }}
85
- .stButton>button {{
86
- color: {primary_color};
87
- background-color: {secondary_color};
88
- border-radius: 8px;
89
- transition: all 0.3s;
90
- }}
91
- .history-box {{
92
- border-left: 4px solid {secondary_color};
93
- padding: 1rem;
94
- margin: 1rem 0;
95
- background-color: {secondary_color};
96
- border-radius: 8px;
97
- }}
98
- </style>
99
- """,
100
- unsafe_allow_html=True
101
- )
102
-
103
- # Inicializar historial
104
- if 'history' not in st.session_state:
105
- st.session_state.history = []
106
-
107
- # Variable auxiliar para gestionar el input
108
- if 'temp_input' not in st.session_state:
109
- st.session_state.temp_input = ""
110
-
111
  # Título de la aplicación
112
- st.title("🧮 MathQA - Asistente de Matemáticas")
113
- st.markdown("")
114
-
115
- # Widget de entrada con variable auxiliar
116
- user_input = st.text_input(
117
- "Escribe tu pregunta matemática aquí:",
118
- value=st.session_state.temp_input,
119
- key="user_input",
120
- placeholder="Ej: ¿Que es una integral?"
121
- )
122
 
123
- # Botón de acción
124
- col1, col2, col3 = st.columns([5, 4, 4]) # Columnas vacías a los lados para centrar
125
- with col2:
126
- if st.button("Resolver pregunta"):
127
- if user_input: # Accedemos al valor ingresado
128
- # Simular respuesta
129
- mock_answer = src.model_load.ask(user_input, retriever)
130
-
131
- # Agregar al historial
132
- st.session_state.history.insert(0, (user_input, mock_answer))
133
-
134
- # Limpiar la variable auxiliar
135
- st.session_state.temp_input = ""
136
 
137
- # Mostrar historial
138
- if st.session_state.history:
139
- st.markdown("---")
140
- st.subheader("Historial de Consultas")
141
-
142
- for idx, (pregunta, respuesta) in enumerate(st.session_state.history):
143
- with st.container():
144
- st.markdown(
145
- f"""
146
- <div class="history-box">
147
- <strong>Pregunta {len(st.session_state.history) - idx}:</strong>
148
- <p>{pregunta}</p>
149
- <strong>Respuesta:</strong>
150
- <p>{respuesta}</p>
151
- </div>
152
- """,
153
- unsafe_allow_html=True
154
- )
155
-
156
- # Pie de página
157
- st.markdown("---")
158
- st.markdown("🔍 ¿Necesitas ayuda con álgebra, cálculo o geometría? ¡Estoy aquí para ayudarte!")
159
-
 
59
  # Carga del modelo y ejecución de la interfaz
60
  qa_chain=src.model_load.load_model()
61
  print("Lanzando interfaz")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  # Título de la aplicación
63
+ st.title("Interfaz Sencilla")
 
 
 
 
 
 
 
 
 
64
 
65
+ # Entrada de texto
66
+ user_input = st.text_input("Escribe algo:")
 
 
 
 
 
 
 
 
 
 
 
67
 
68
+ # Botón para obtener la respuesta
69
+ if st.button("Obtener respuesta"):
70
+ st.write(src.model_load.ask(user_input, retriever))