Phoenix21 commited on
Commit
e6a4ae7
·
verified ·
1 Parent(s): 74c90c3

Update my_memory_logic.py

Browse files
Files changed (1) hide show
  1. my_memory_logic.py +11 -5
my_memory_logic.py CHANGED
@@ -1,5 +1,3 @@
1
- # my_memory_logic.py
2
-
3
  import os
4
 
5
  # Import the PipelineRunnable from pipeline.py
@@ -34,8 +32,16 @@ conversational_rag_chain = RunnableWithMessageHistory(
34
  # 3) Convenience function for session-based memory
35
  ###############################################################################
36
  def run_with_session_memory(user_query: str, session_id: str) -> str:
 
 
 
 
 
 
 
37
  response = conversational_rag_chain.invoke(
38
- {"input": user_query},
39
- config={"configurable": {"session_id": session_id}}
40
  )
41
- return response["answer"]
 
 
 
 
1
  import os
2
 
3
  # Import the PipelineRunnable from pipeline.py
 
32
  # 3) Convenience function for session-based memory
33
  ###############################################################################
34
  def run_with_session_memory(user_query: str, session_id: str) -> str:
35
+ if not user_query:
36
+ raise ValueError("User query is missing. Ensure the 'input' key is provided.")
37
+
38
+ # Prepare input dictionary with the correct structure
39
+ input_data = {"input": user_query}
40
+
41
+ # Ensure the session ID is passed correctly in the configuration
42
  response = conversational_rag_chain.invoke(
43
+ input_data, # Pass the dictionary containing the 'input' key
44
+ config={"configurable": {"session_id": session_id}} # Pass session ID in the config
45
  )
46
+
47
+ return response.get("answer", "No answer returned from the chain.")