Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,7 +137,7 @@ Examples:
|
|
| 137 |
|
| 138 |
chain = expand_prompt | llm | StrOutputParser()
|
| 139 |
expanded_query = chain.invoke({"query": state['query'], "query_feedback":state["query_feedback"]})
|
| 140 |
-
|
| 141 |
state["expanded_query"] = expanded_query
|
| 142 |
return state
|
| 143 |
|
|
@@ -168,11 +168,11 @@ def retrieve_context(state):
|
|
| 168 |
"""
|
| 169 |
print("---------retrieve_context---------")
|
| 170 |
query = state['expanded_query'] # Complete the code to define the key for the expanded query
|
| 171 |
-
|
| 172 |
|
| 173 |
# Retrieve documents from the vector store
|
| 174 |
docs = retriever.invoke(query)
|
| 175 |
-
|
| 176 |
|
| 177 |
# Extract both page_content and metadata from each document
|
| 178 |
context = [
|
|
@@ -186,7 +186,7 @@ def retrieve_context(state):
|
|
| 186 |
]
|
| 187 |
state['context'] = context # Complete the code to define the key for storing the context
|
| 188 |
#print("Extracted context with metadata:", context) # Debugging: Print the extracted context
|
| 189 |
-
|
| 190 |
return state
|
| 191 |
|
| 192 |
|
|
@@ -221,7 +221,7 @@ If the context does not contain enough information to answer accurately, clearly
|
|
| 221 |
"feedback": state.get('feedback', 'No feedback provided') # add feedback to the prompt
|
| 222 |
})
|
| 223 |
state['response'] = response
|
| 224 |
-
|
| 225 |
|
| 226 |
return state
|
| 227 |
|
|
@@ -337,7 +337,7 @@ Focus on biblical coherence, faith-based reasoning, and alignment with the theme
|
|
| 337 |
|
| 338 |
# Store response suggestions in a structured format
|
| 339 |
feedback = f"Previous Response: {state['response']}\nSuggestions: {chain.invoke({'query': state['query'], 'response': state['response']})}"
|
| 340 |
-
|
| 341 |
print(f"State: {state}")
|
| 342 |
state['feedback'] = feedback
|
| 343 |
return state
|
|
@@ -370,7 +370,7 @@ Focus on biblical coherence, faith-based reasoning, and alignment with the theme
|
|
| 370 |
|
| 371 |
# Store refinement suggestions without modifying the original expanded query
|
| 372 |
query_feedback = f"Previous Expanded Query: {state['expanded_query']}\nSuggestions: {chain.invoke({'query': state['query'], 'expanded_query': state['expanded_query']})}"
|
| 373 |
-
|
| 374 |
print(f"Groundedness loop count: {state['groundedness_loop_count']}")
|
| 375 |
state['query_feedback'] = query_feedback
|
| 376 |
return state
|
|
@@ -710,7 +710,7 @@ def spritual_assistant_streamlit():
|
|
| 710 |
st.session_state.user_id = user_id
|
| 711 |
st.session_state.chat_history.append({
|
| 712 |
"role": "assistant",
|
| 713 |
-
"content": f"Welcome ใใใใ , {user_id}! How can I guide you in your spiritual path today?"
|
| 714 |
})
|
| 715 |
st.session_state.login_submitted = True
|
| 716 |
if st.session_state.get("login_submitted", False):
|
|
|
|
| 137 |
|
| 138 |
chain = expand_prompt | llm | StrOutputParser()
|
| 139 |
expanded_query = chain.invoke({"query": state['query'], "query_feedback":state["query_feedback"]})
|
| 140 |
+
print("expanded_query", expanded_query) #uncomment this line to see expanded query
|
| 141 |
state["expanded_query"] = expanded_query
|
| 142 |
return state
|
| 143 |
|
|
|
|
| 168 |
"""
|
| 169 |
print("---------retrieve_context---------")
|
| 170 |
query = state['expanded_query'] # Complete the code to define the key for the expanded query
|
| 171 |
+
print("Query used for retrieval:", query) # Debugging: Print the query
|
| 172 |
|
| 173 |
# Retrieve documents from the vector store
|
| 174 |
docs = retriever.invoke(query)
|
| 175 |
+
print("Retrieved documents:", docs) # Debugging: Print the raw docs object
|
| 176 |
|
| 177 |
# Extract both page_content and metadata from each document
|
| 178 |
context = [
|
|
|
|
| 186 |
]
|
| 187 |
state['context'] = context # Complete the code to define the key for storing the context
|
| 188 |
#print("Extracted context with metadata:", context) # Debugging: Print the extracted context
|
| 189 |
+
print(f"Groundedness loop count: {state['groundedness_loop_count']}")
|
| 190 |
return state
|
| 191 |
|
| 192 |
|
|
|
|
| 221 |
"feedback": state.get('feedback', 'No feedback provided') # add feedback to the prompt
|
| 222 |
})
|
| 223 |
state['response'] = response
|
| 224 |
+
print("intermediate response: ", response) #uncomment this line to see intermediate response
|
| 225 |
|
| 226 |
return state
|
| 227 |
|
|
|
|
| 337 |
|
| 338 |
# Store response suggestions in a structured format
|
| 339 |
feedback = f"Previous Response: {state['response']}\nSuggestions: {chain.invoke({'query': state['query'], 'response': state['response']})}"
|
| 340 |
+
print("feedback: ", feedback) #uncomment this line to see feedback
|
| 341 |
print(f"State: {state}")
|
| 342 |
state['feedback'] = feedback
|
| 343 |
return state
|
|
|
|
| 370 |
|
| 371 |
# Store refinement suggestions without modifying the original expanded query
|
| 372 |
query_feedback = f"Previous Expanded Query: {state['expanded_query']}\nSuggestions: {chain.invoke({'query': state['query'], 'expanded_query': state['expanded_query']})}"
|
| 373 |
+
print("query_feedback: ", query_feedback)
|
| 374 |
print(f"Groundedness loop count: {state['groundedness_loop_count']}")
|
| 375 |
state['query_feedback'] = query_feedback
|
| 376 |
return state
|
|
|
|
| 710 |
st.session_state.user_id = user_id
|
| 711 |
st.session_state.chat_history.append({
|
| 712 |
"role": "assistant",
|
| 713 |
+
"content": f"Welcome ใใใใ , {user_id}! How can I guide you in your spiritual path today? ไปๆฅใใใชใใฎ็ฒพ็ฅ็ใช้ใใฉใฎใใใซๅฐใใใจใใงใใใงใใใใ? "
|
| 714 |
})
|
| 715 |
st.session_state.login_submitted = True
|
| 716 |
if st.session_state.get("login_submitted", False):
|