Spaces:
Running
Running
Commit ·
e65d466
1
Parent(s): 0f8e961
Fix PDF analysis bypassing FAQ matcher to send statement to AI
Browse files
app.py
CHANGED
|
@@ -1096,9 +1096,11 @@ def show_dashboard():
|
|
| 1096 |
prompt = st.chat_input(t("chat_input"))
|
| 1097 |
|
| 1098 |
display_prompt = prompt
|
|
|
|
| 1099 |
if getattr(st.session_state, 'faq_trigger', None):
|
| 1100 |
prompt = st.session_state.faq_trigger
|
| 1101 |
display_prompt = getattr(st.session_state, 'faq_display', prompt)
|
|
|
|
| 1102 |
st.session_state.faq_trigger = None
|
| 1103 |
st.session_state.faq_display = None
|
| 1104 |
|
|
@@ -1108,7 +1110,8 @@ def show_dashboard():
|
|
| 1108 |
with chat_container:
|
| 1109 |
st.markdown(f'<div class="user-bubble">{display_prompt}</div>', unsafe_allow_html=True)
|
| 1110 |
|
| 1111 |
-
|
|
|
|
| 1112 |
|
| 1113 |
res_box = st.empty()
|
| 1114 |
full_response = ""
|
|
@@ -1116,7 +1119,7 @@ def show_dashboard():
|
|
| 1116 |
if faq_response:
|
| 1117 |
full_response = faq_response
|
| 1118 |
res_box.markdown(f'<div class="ai-bubble">{full_response}</div>', unsafe_allow_html=True)
|
| 1119 |
-
elif is_banking_query(prompt):
|
| 1120 |
if check_ollama_connection():
|
| 1121 |
last_update_time = time.time()
|
| 1122 |
for chunk in stream_ai_response(prompt, history=st.session_state.messages[:-1]):
|
|
|
|
| 1096 |
prompt = st.chat_input(t("chat_input"))
|
| 1097 |
|
| 1098 |
display_prompt = prompt
|
| 1099 |
+
is_pdf_analysis = False
|
| 1100 |
if getattr(st.session_state, 'faq_trigger', None):
|
| 1101 |
prompt = st.session_state.faq_trigger
|
| 1102 |
display_prompt = getattr(st.session_state, 'faq_display', prompt)
|
| 1103 |
+
is_pdf_analysis = st.session_state.get('faq_display', '').startswith("I have uploaded")
|
| 1104 |
st.session_state.faq_trigger = None
|
| 1105 |
st.session_state.faq_display = None
|
| 1106 |
|
|
|
|
| 1110 |
with chat_container:
|
| 1111 |
st.markdown(f'<div class="user-bubble">{display_prompt}</div>', unsafe_allow_html=True)
|
| 1112 |
|
| 1113 |
+
# Skip FAQ for PDF analysis — send directly to AI
|
| 1114 |
+
faq_response = None if is_pdf_analysis else get_faq_response(prompt, language=st.session_state.get("language", "English"))
|
| 1115 |
|
| 1116 |
res_box = st.empty()
|
| 1117 |
full_response = ""
|
|
|
|
| 1119 |
if faq_response:
|
| 1120 |
full_response = faq_response
|
| 1121 |
res_box.markdown(f'<div class="ai-bubble">{full_response}</div>', unsafe_allow_html=True)
|
| 1122 |
+
elif is_pdf_analysis or is_banking_query(prompt):
|
| 1123 |
if check_ollama_connection():
|
| 1124 |
last_update_time = time.time()
|
| 1125 |
for chunk in stream_ai_response(prompt, history=st.session_state.messages[:-1]):
|