Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,7 @@ if not st.session_state.chunked: # Ensure chunking only happens once
|
|
| 104 |
st.session_state.documents = cached_chunks
|
| 105 |
st.session_state.chunked = True
|
| 106 |
|
| 107 |
-
# Step 3: Chunking
|
| 108 |
if st.session_state.pdf_loaded and not st.session_state.chunked:
|
| 109 |
with st.spinner("Chunking the document..."):
|
| 110 |
try:
|
|
@@ -188,9 +188,9 @@ if query:
|
|
| 188 |
#st.write("Extracted Context (page_content):", context)
|
| 189 |
#st.write("Number of Extracted Contexts:", len(context))
|
| 190 |
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
|
| 195 |
|
| 196 |
relevancy_prompt = """You are an expert judge tasked with evaluating whether the EACH OF THE CONTEXT provided in the CONTEXT LIST is self sufficient to answer the QUERY asked.
|
|
@@ -316,30 +316,24 @@ if query:
|
|
| 316 |
|
| 317 |
#st.subheader('final_output["relevancy_response"]')
|
| 318 |
#st.write(final_output["relevancy_response"] )
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
else:
|
| 341 |
-
st.warning("β οΈ No retrieved context available.")
|
| 342 |
-
|
| 343 |
-
# π Retrieved Context Numbers
|
| 344 |
-
st.markdown("### π **Relevant Context Numbers**")
|
| 345 |
-
st.write(final_output["context_number"])
|
|
|
|
| 104 |
st.session_state.documents = cached_chunks
|
| 105 |
st.session_state.chunked = True
|
| 106 |
|
| 107 |
+
# Step 3: Chunking (Only Happens Once)
|
| 108 |
if st.session_state.pdf_loaded and not st.session_state.chunked:
|
| 109 |
with st.spinner("Chunking the document..."):
|
| 110 |
try:
|
|
|
|
| 188 |
#st.write("Extracted Context (page_content):", context)
|
| 189 |
#st.write("Number of Extracted Contexts:", len(context))
|
| 190 |
|
| 191 |
+
st.write("π **Relevant Passages Retrieved:**")
|
| 192 |
+
for idx, doc in enumerate(contexts):
|
| 193 |
+
st.write(f"**Excerpt {idx+1}:** {doc.page_content}")
|
| 194 |
|
| 195 |
|
| 196 |
relevancy_prompt = """You are an expert judge tasked with evaluating whether the EACH OF THE CONTEXT provided in the CONTEXT LIST is self sufficient to answer the QUERY asked.
|
|
|
|
| 316 |
|
| 317 |
#st.subheader('final_output["relevancy_response"]')
|
| 318 |
#st.write(final_output["relevancy_response"] )
|
| 319 |
+
|
| 320 |
+
st.write("π **Relevance Analysis:**")
|
| 321 |
+
if isinstance(final_output["relevancy_response"], list):
|
| 322 |
+
for item in final_output["relevancy_response"]:
|
| 323 |
+
st.write(f"β
**Context {item.get('content', 'N/A')} - Score: {item.get('score', 'N/A')}**")
|
| 324 |
+
st.write(f"**Reasoning:** {item.get('Reasoning', 'No explanation provided.')}")
|
| 325 |
+
else:
|
| 326 |
+
st.write("β οΈ No relevance analysis available.")
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
st.subheader('final_output["context_number"]')
|
| 330 |
+
st.write(final_output["context_number"])
|
| 331 |
+
|
| 332 |
+
st.subheader('final_output["relevant_contexts"]')
|
| 333 |
+
st.write(final_output["relevant_contexts"])
|
| 334 |
+
|
| 335 |
+
#st.subheader('final_output["final_response"]')
|
| 336 |
+
#st.write(final_output["final_response"])
|
| 337 |
+
|
| 338 |
+
st.subheader("π’ **Final Answer:**")
|
| 339 |
+
st.write(final_output["final_response"] if final_output["final_response"] else "β οΈ No clear answer found based on retrieved content.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|