Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -180,18 +180,13 @@ if query:
|
|
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 |
-
|
184 |
-
|
185 |
|
186 |
context = [d.page_content for d in contexts]
|
187 |
# Debugging: Check extracted context
|
188 |
-
|
189 |
-
|
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.
|
197 |
Analyze the provided QUERY AND CONTEXT to determine if each Ccontent in the CONTEXT LIST contains Relevant information to answer the QUERY.
|
@@ -314,17 +309,8 @@ if query:
|
|
314 |
|
315 |
final_output = context_management_chain({"context":context,"retriever_query":query,"query":query})
|
316 |
|
317 |
-
|
318 |
-
|
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"])
|
@@ -332,8 +318,5 @@ if query:
|
|
332 |
st.subheader('final_output["relevant_contexts"]')
|
333 |
st.write(final_output["relevant_contexts"])
|
334 |
|
335 |
-
|
336 |
-
|
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.")
|
|
|
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)
|
184 |
+
st.write("Number of Contexts:", len(contexts))
|
185 |
|
186 |
context = [d.page_content for d in contexts]
|
187 |
# Debugging: Check extracted context
|
188 |
+
st.write("Extracted Context (page_content):", context)
|
189 |
+
st.write("Number of Extracted Contexts:", len(context))
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
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.
|
192 |
Analyze the provided QUERY AND CONTEXT to determine if each Ccontent in the CONTEXT LIST contains Relevant information to answer the QUERY.
|
|
|
309 |
|
310 |
final_output = context_management_chain({"context":context,"retriever_query":query,"query":query})
|
311 |
|
312 |
+
st.subheader('final_output["relevancy_response"]')
|
313 |
+
st.write(final_output["relevancy_response"] )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
st.subheader('final_output["context_number"]')
|
316 |
st.write(final_output["context_number"])
|
|
|
318 |
st.subheader('final_output["relevant_contexts"]')
|
319 |
st.write(final_output["relevant_contexts"])
|
320 |
|
321 |
+
st.subheader('final_output["final_response"]')
|
322 |
+
st.write(final_output["final_response"])
|
|
|
|
|
|