ankanghosh commited on
Commit
37b582d
·
verified ·
1 Parent(s): 913341a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -21
app.py CHANGED
@@ -46,6 +46,14 @@ st.markdown("""
46
  overflow: hidden !important;
47
  text-overflow: ellipsis !important;
48
  }
 
 
 
 
 
 
 
 
49
  .stButton>button:hover {
50
  background-color: #fafbff !important;
51
  border-color: #c5cae9 !important;
@@ -101,18 +109,11 @@ div.stInfo {
101
  gap: 10px;
102
  }
103
 
104
- /* Form submit button styling to match other buttons */
105
- button[kind="formSubmit"] {
106
- background-color: #fff0f0 !important;
107
- color: #3f51b5 !important;
108
- border: 1px solid #e1e4f2 !important;
109
- border-radius: 20px !important;
110
- padding: 8px 16px !important;
111
- box-shadow: 0 1px 2px rgba(0,0,0,0.03) !important;
112
- }
113
- button[kind="formSubmit"]:hover {
114
- background-color: #fafbff !important;
115
- border-color: #c5cae9 !important;
116
  }
117
  </style>
118
  <div class="main-title">Spirituality Q&A</div>
@@ -200,13 +201,13 @@ for row_idx, row in enumerate(question_rows):
200
  if st.button(q, key=f"r{row_idx}_q{i}", use_container_width=True):
201
  set_query(q)
202
 
203
- # Function to handle form submission with enter key handling
204
  def handle_form_submit():
205
  if st.session_state.query_input and st.session_state.query_input.strip():
206
  st.session_state.last_query = st.session_state.query_input.strip()
207
  st.session_state.submit_clicked = True
208
- # Clear input and focus out to reset border color
209
- st.session_state.query_input = ""
210
  st.rerun()
211
 
212
  # Create a form with dynamic key for resetting
@@ -233,12 +234,7 @@ if st.session_state.submit_clicked and st.session_state.last_query:
233
 
234
  with st.spinner("Processing your question..."):
235
  try:
236
- # result = process_query(st.session_state.last_query, top_k=top_k, word_limit=word_limit)
237
- # Mock answer for testing
238
- result = {
239
- "answer_with_rag": "🔹 This is a placeholder answer for testing UI.",
240
- "citations": "🔹 Sample Source 1\n🔹 Sample Source 2"
241
- }
242
  st.subheader("Answer:")
243
  st.write(result["answer_with_rag"])
244
  st.subheader("Sources:")
 
46
  overflow: hidden !important;
47
  text-overflow: ellipsis !important;
48
  }
49
+
50
+ /* Form submit button specific styling */
51
+ button[type="submit"],
52
+ .stFormSubmit>button,
53
+ [data-testid="stFormSubmitButton"]>button {
54
+ background-color: #fff0f0 !important;
55
+ color: #3f51b5 !important;
56
+ }
57
  .stButton>button:hover {
58
  background-color: #fafbff !important;
59
  border-color: #c5cae9 !important;
 
109
  gap: 10px;
110
  }
111
 
112
+ /* Placeholder for buttons */
113
+ .button-placeholder {
114
+ min-height: 38px;
115
+ min-width: 120px;
116
+ margin: 0 5px;
 
 
 
 
 
 
 
117
  }
118
  </style>
119
  <div class="main-title">Spirituality Q&A</div>
 
201
  if st.button(q, key=f"r{row_idx}_q{i}", use_container_width=True):
202
  set_query(q)
203
 
204
+ # Function to handle form submission
205
  def handle_form_submit():
206
  if st.session_state.query_input and st.session_state.query_input.strip():
207
  st.session_state.last_query = st.session_state.query_input.strip()
208
  st.session_state.submit_clicked = True
209
+ # Increment the form key to force a reset
210
+ st.session_state.form_key += 1
211
  st.rerun()
212
 
213
  # Create a form with dynamic key for resetting
 
234
 
235
  with st.spinner("Processing your question..."):
236
  try:
237
+ result = process_query(st.session_state.last_query, top_k=top_k, word_limit=word_limit)
 
 
 
 
 
238
  st.subheader("Answer:")
239
  st.write(result["answer_with_rag"])
240
  st.subheader("Sources:")