Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -52,6 +52,9 @@ st.markdown("""
|
|
52 |
border: 1px solid #ccc !important;
|
53 |
border-radius: 8px !important;
|
54 |
padding: 0.5em !important;
|
|
|
|
|
|
|
55 |
}
|
56 |
::placeholder {
|
57 |
color: #ccc !important;
|
@@ -62,7 +65,6 @@ st.markdown("""
|
|
62 |
border-radius: 8px !important;
|
63 |
padding: 0.5em !important;
|
64 |
}
|
65 |
-
/* SOLO APLICA A BOTONES DEL SIDEBAR */
|
66 |
section[data-testid="stSidebar"] div[data-testid="stButton"] > button {
|
67 |
background-color: #526366 !important;
|
68 |
color: white !important;
|
@@ -73,7 +75,6 @@ st.markdown("""
|
|
73 |
width: 80% !important;
|
74 |
margin-bottom: 0.5em;
|
75 |
}
|
76 |
-
/* APLICA A BOTONES FUERA DEL SIDEBAR (ej: Send question) */
|
77 |
div[data-testid="stButton"] > button {
|
78 |
background-color: #526366 !important;
|
79 |
color: white !important;
|
@@ -222,21 +223,22 @@ selected_ideology = st.session_state.selected_ideology
|
|
222 |
|
223 |
if selected_ideology:
|
224 |
st.write(f"You have selected: **{selected_ideology}**")
|
225 |
-
user_query = st.text_area("Write your question or political dilemma:", height=100)
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
240 |
|
241 |
if "response" in st.session_state and st.session_state.selected_ideology:
|
242 |
st.subheader("🤖 Generated response:")
|
|
|
52 |
border: 1px solid #ccc !important;
|
53 |
border-radius: 8px !important;
|
54 |
padding: 0.5em !important;
|
55 |
+
resize: none !important;
|
56 |
+
transition: none !important;
|
57 |
+
will-change: auto !important;
|
58 |
}
|
59 |
::placeholder {
|
60 |
color: #ccc !important;
|
|
|
65 |
border-radius: 8px !important;
|
66 |
padding: 0.5em !important;
|
67 |
}
|
|
|
68 |
section[data-testid="stSidebar"] div[data-testid="stButton"] > button {
|
69 |
background-color: #526366 !important;
|
70 |
color: white !important;
|
|
|
75 |
width: 80% !important;
|
76 |
margin-bottom: 0.5em;
|
77 |
}
|
|
|
78 |
div[data-testid="stButton"] > button {
|
79 |
background-color: #526366 !important;
|
80 |
color: white !important;
|
|
|
223 |
|
224 |
if selected_ideology:
|
225 |
st.write(f"You have selected: **{selected_ideology}**")
|
|
|
226 |
|
227 |
+
user_query = st.text_area("Write your question or political dilemma:", height=100, key="user_input")
|
228 |
+
|
229 |
+
if selected_ideology and st.button("Send question"):
|
230 |
+
if user_query.strip() == "":
|
231 |
+
st.warning("Write a question before continuing.")
|
232 |
+
else:
|
233 |
+
with st.spinner("Thinking like that ideology..."):
|
234 |
+
query_emb = embed_query(user_query + " in the context of " + selected_ideology)
|
235 |
+
index, metadata, chunks = load_data_global()
|
236 |
+
context = search_in_global_index(query_emb, index, metadata, chunks, selected_ideology, k=5)
|
237 |
+
response = generate_rag_response(selected_ideology, user_query, context)
|
238 |
+
|
239 |
+
st.session_state.response = response
|
240 |
+
st.session_state.context = context
|
241 |
+
st.session_state.last_query = user_query
|
242 |
|
243 |
if "response" in st.session_state and st.session_state.selected_ideology:
|
244 |
st.subheader("🤖 Generated response:")
|