Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -177,7 +177,7 @@ elif st.session_state.pdf_loaded and st.session_state.chunked and st.session_sta
|
|
177 |
|
178 |
if query:
|
179 |
with st.spinner("π Retrieving relevant context..."):
|
180 |
-
retriever = st.session_state.vector_store.as_retriever(search_type="similarity", search_kwargs={"k":
|
181 |
contexts = retriever.invoke(query)
|
182 |
# Debugging: Check what was retrieved
|
183 |
#st.write("Retrieved Contexts:", contexts)
|
@@ -206,8 +206,8 @@ if query:
|
|
206 |
- 0: The content has all the necessary information to answer the QUERY
|
207 |
- 1: The content does not has the necessary information to answer the QUERY
|
208 |
|
209 |
-
|
210 |
-
|
211 |
INPUT (for context only, not to be used for faithfulness evaluation):
|
212 |
What is the capital of France?
|
213 |
|
@@ -220,7 +220,7 @@ if query:
|
|
220 |
|
221 |
RESPONSE:
|
222 |
{{"score":0}}
|
223 |
-
|
224 |
|
225 |
CONTENT LIST:
|
226 |
{context}
|
@@ -314,30 +314,28 @@ if query:
|
|
314 |
|
315 |
final_output = context_management_chain({"context":context,"retriever_query":query,"query":query})
|
316 |
|
317 |
-
st.
|
318 |
-
st.
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
st.markdown("### π **Relevant Context Numbers**")
|
341 |
-
st.write(final_output["context_number"])
|
342 |
|
343 |
|
|
|
177 |
|
178 |
if query:
|
179 |
with st.spinner("π Retrieving relevant context..."):
|
180 |
+
retriever = st.session_state.vector_store.as_retriever(search_type="similarity", search_kwargs={"k": 3})
|
181 |
contexts = retriever.invoke(query)
|
182 |
# Debugging: Check what was retrieved
|
183 |
#st.write("Retrieved Contexts:", contexts)
|
|
|
206 |
- 0: The content has all the necessary information to answer the QUERY
|
207 |
- 1: The content does not has the necessary information to answer the QUERY
|
208 |
|
209 |
+
|
210 |
+
EXAMPLE:
|
211 |
INPUT (for context only, not to be used for faithfulness evaluation):
|
212 |
What is the capital of France?
|
213 |
|
|
|
220 |
|
221 |
RESPONSE:
|
222 |
{{"score":0}}
|
223 |
+
|
224 |
|
225 |
CONTENT LIST:
|
226 |
{context}
|
|
|
314 |
|
315 |
final_output = context_management_chain({"context":context,"retriever_query":query,"query":query})
|
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.")
|
|
|
|
|
340 |
|
341 |
|