Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ footer {
|
|
| 108 |
margin-bottom: 6px;
|
| 109 |
}
|
| 110 |
|
| 111 |
-
/* 7. HIDE UPLOADED FILE LIST & NAME
|
| 112 |
[data-testid='stFileUploaderFile'] {
|
| 113 |
display: none;
|
| 114 |
}
|
|
@@ -270,6 +270,7 @@ FINAL ANSWER:"""
|
|
| 270 |
],
|
| 271 |
temperature=0.0
|
| 272 |
)
|
|
|
|
| 273 |
return response.choices[0].message.content.strip(), len(docs), None
|
| 274 |
except Exception as e:
|
| 275 |
return None, 0, f"Error: {str(e)}"
|
|
@@ -297,7 +298,6 @@ with st.sidebar:
|
|
| 297 |
chunks = process_pdf(uploaded)
|
| 298 |
if chunks:
|
| 299 |
st.session_state.uploaded_file_name = uploaded.name
|
| 300 |
-
# CHANGED: Simple message without chunk count
|
| 301 |
st.success("✅ PDF Processed!")
|
| 302 |
else:
|
| 303 |
st.error("❌ Failed.")
|
|
@@ -327,6 +327,7 @@ if submit_btn and user_question:
|
|
| 327 |
with st.spinner("Thinking..."):
|
| 328 |
answer, sources, error = ask_question(user_question)
|
| 329 |
if answer:
|
|
|
|
| 330 |
bot_msg = f"{answer}<div class='sources'>Context Chunks Used: {sources}</div>"
|
| 331 |
st.session_state.chat.append(("bot", bot_msg))
|
| 332 |
else:
|
|
|
|
| 108 |
margin-bottom: 6px;
|
| 109 |
}
|
| 110 |
|
| 111 |
+
/* 7. HIDE UPLOADED FILE LIST & NAME */
|
| 112 |
[data-testid='stFileUploaderFile'] {
|
| 113 |
display: none;
|
| 114 |
}
|
|
|
|
| 270 |
],
|
| 271 |
temperature=0.0
|
| 272 |
)
|
| 273 |
+
# Returns: (Answer Text, Number of Chunks, Error)
|
| 274 |
return response.choices[0].message.content.strip(), len(docs), None
|
| 275 |
except Exception as e:
|
| 276 |
return None, 0, f"Error: {str(e)}"
|
|
|
|
| 298 |
chunks = process_pdf(uploaded)
|
| 299 |
if chunks:
|
| 300 |
st.session_state.uploaded_file_name = uploaded.name
|
|
|
|
| 301 |
st.success("✅ PDF Processed!")
|
| 302 |
else:
|
| 303 |
st.error("❌ Failed.")
|
|
|
|
| 327 |
with st.spinner("Thinking..."):
|
| 328 |
answer, sources, error = ask_question(user_question)
|
| 329 |
if answer:
|
| 330 |
+
# THIS LINE ENSURES THE "Context Chunks Used" MESSAGE APPEARS IN THE CHAT RESPONSE
|
| 331 |
bot_msg = f"{answer}<div class='sources'>Context Chunks Used: {sources}</div>"
|
| 332 |
st.session_state.chat.append(("bot", bot_msg))
|
| 333 |
else:
|