🐛 fix(endpoints.py): fix response and session_id assignment in process_flow function

🐛 fix(schemas.py): add session_id field to ProcessResponse schema
🐛 fix(process.py): fix session_id assignment in process_graph_cached function
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-08 10:42:58 -03:00
commit 6af7d04d4e
3 changed files with 6 additions and 4 deletions

View file

@ -91,10 +91,10 @@ async def process_flow(
graph_data = process_tweaks(graph_data, tweaks)
except Exception as exc:
logger.error(f"Error processing tweaks: {exc}")
response = process_graph_cached(graph_data, inputs, clear_cache, session_id)
return ProcessResponse(
result=response,
response, session_id = process_graph_cached(
graph_data, inputs, clear_cache, session_id
)
return ProcessResponse(result=response, session_id=session_id)
except Exception as e:
# Log stack trace
logger.exception(e)

View file

@ -47,6 +47,7 @@ class ProcessResponse(BaseModel):
"""Process response schema."""
result: dict
session_id: str = None
class ChatMessage(BaseModel):

View file

@ -117,6 +117,7 @@ def process_graph_cached(
logger.debug("Cleared cache")
langchain_object, artifacts = get_build_result(data_graph, session_id)
session_id = build_sorted_vertices_with_caching.hash
logger.debug("Loaded LangChain object")
if inputs is None:
@ -151,7 +152,7 @@ def process_graph_cached(
raise ValueError(
f"Unknown langchain_object type: {type(langchain_object).__name__}"
)
return result
return result, session_id
def load_flow_from_json(