Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,6 +117,7 @@ question = st.text_input('Write your question below:')
|
|
| 117 |
if st.button('Enter'):
|
| 118 |
if question:
|
| 119 |
answer = get_answer(question)
|
|
|
|
| 120 |
st.session_state.custom_answer = f"**Answer:** {answer}"
|
| 121 |
else:
|
| 122 |
st.write("Please enter a question.")
|
|
@@ -126,16 +127,19 @@ if st.session_state.custom_answer:
|
|
| 126 |
st.session_state.faq_answer = "" # Clear FAQ answer when a custom question is asked
|
| 127 |
st.write(st.session_state.custom_answer)
|
| 128 |
|
| 129 |
-
# Show
|
| 130 |
faq_expander = st.sidebar.expander("FAQs")
|
| 131 |
with faq_expander:
|
| 132 |
for i, faq in enumerate(faq_questions):
|
| 133 |
if st.sidebar.button(f"Q{i+1}: {faq}", key=f"faq{i+1}"):
|
| 134 |
-
st.session_state.
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
| 139 |
st.write(st.session_state.faq_answer)
|
| 140 |
|
| 141 |
|
|
|
|
| 117 |
if st.button('Enter'):
|
| 118 |
if question:
|
| 119 |
answer = get_answer(question)
|
| 120 |
+
st.session_state.faq_answer = "" # Clear FAQ answer when a custom question is asked
|
| 121 |
st.session_state.custom_answer = f"**Answer:** {answer}"
|
| 122 |
else:
|
| 123 |
st.write("Please enter a question.")
|
|
|
|
| 127 |
st.session_state.faq_answer = "" # Clear FAQ answer when a custom question is asked
|
| 128 |
st.write(st.session_state.custom_answer)
|
| 129 |
|
| 130 |
+
# Show FAQ questions
|
| 131 |
faq_expander = st.sidebar.expander("FAQs")
|
| 132 |
with faq_expander:
|
| 133 |
for i, faq in enumerate(faq_questions):
|
| 134 |
if st.sidebar.button(f"Q{i+1}: {faq}", key=f"faq{i+1}"):
|
| 135 |
+
st.session_state.custom_answer = "" # Clear custom answer when FAQ is clicked
|
| 136 |
+
st.session_state.faq_answer = f"**Answer to Q{i+1}: {precomputed_faq_answers[faq]}**"
|
| 137 |
|
| 138 |
+
|
| 139 |
+
# Display the answer to the selected FAQ or custom question in the main window
|
| 140 |
+
if st.session_state.custom_answer:
|
| 141 |
+
st.write(st.session_state.custom_answer)
|
| 142 |
+
elif st.session_state.faq_answer:
|
| 143 |
st.write(st.session_state.faq_answer)
|
| 144 |
|
| 145 |
|