🐛 fix(process.py): remove unnecessary else statement to improve code readability and semantics
🐛 fix(process.py): update session_manager.update_session() method signature to match the new implementation 🐛 fix(worker.py): update session_manager.update_session() method signature to match the new implementation 🐛 fix(test_process.py): update session_manager.build_key() and session_manager.clear_session() method calls to match the new implementation
This commit is contained in:
parent
141f57958b
commit
5903378503
3 changed files with 6 additions and 11 deletions
|
|
@ -192,17 +192,13 @@ async def process_graph_cached(
|
|||
session_id = session_manager.generate_key(
|
||||
session_id=session_id, data_graph=data_graph
|
||||
)
|
||||
else:
|
||||
session_id = session_manager.build_key(session_id, data_graph)
|
||||
# Load the graph using SessionManager
|
||||
langchain_object, artifacts = session_manager.load_session(session_id, data_graph)
|
||||
processed_inputs = process_inputs(inputs, artifacts)
|
||||
result = generate_result(langchain_object, processed_inputs)
|
||||
# langchain_object is now updated with the new memory
|
||||
# we need to update the cache with the updated langchain_object
|
||||
session_manager.update_session(
|
||||
session_id, data_graph, (langchain_object, artifacts)
|
||||
)
|
||||
session_manager.update_session(session_id, (langchain_object, artifacts))
|
||||
|
||||
return Result(result, session_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ def process_graph_cached_task(
|
|||
result = generate_result(langchain_object, processed_inputs)
|
||||
# langchain_object is now updated with the new memory
|
||||
# we need to update the cache with the updated langchain_object
|
||||
session_manager.update_session(
|
||||
session_id, data_graph, (langchain_object, artifacts)
|
||||
)
|
||||
session_manager.update_session(session_id, (langchain_object, artifacts))
|
||||
|
||||
return result, session_id
|
||||
|
|
|
|||
|
|
@ -217,14 +217,15 @@ def test_load_langchain_object_with_no_cached_session(client, basic_graph_data):
|
|||
# Provide a non-existent session_id
|
||||
session_manager = get_session_manager()
|
||||
session_id1 = "non-existent-session-id"
|
||||
session_id = session_manager.build_key(session_id1, basic_graph_data)
|
||||
langchain_object1, artifacts1 = session_manager.load_session(
|
||||
session_id1, basic_graph_data
|
||||
session_id, basic_graph_data
|
||||
)
|
||||
# Clear the cache
|
||||
session_manager.clear_session(session_id1, basic_graph_data)
|
||||
session_manager.clear_session(session_id)
|
||||
# Use the new session_id to get the langchain_object again
|
||||
langchain_object2, artifacts2 = session_manager.load_session(
|
||||
session_id1, basic_graph_data
|
||||
session_id, basic_graph_data
|
||||
)
|
||||
|
||||
assert id(langchain_object1) != id(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue