Spaces:
Sleeping
Sleeping
Prueba con interfaz sencilla
Browse files
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("
|
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 |
-
#
|
124 |
-
|
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 |
-
#
|
138 |
-
if st.
|
139 |
-
st.
|
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))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|