Refactor run_graph function to generate session_id if not provided
This commit is contained in:
parent
0a77490f8c
commit
8dd3cccfbe
1 changed files with 8 additions and 1 deletions
|
|
@ -277,12 +277,19 @@ async def run_graph(
|
||||||
):
|
):
|
||||||
"""Run the graph and generate the result"""
|
"""Run the graph and generate the result"""
|
||||||
if isinstance(graph, dict):
|
if isinstance(graph, dict):
|
||||||
|
graph_data = graph
|
||||||
graph = Graph.from_payload(graph, flow_id=flow_id)
|
graph = Graph.from_payload(graph, flow_id=flow_id)
|
||||||
|
else:
|
||||||
|
graph_data = graph._graph_data
|
||||||
|
if not session_id:
|
||||||
|
session_id = session_service.generate_key(
|
||||||
|
session_id=flow_id, data_graph=graph_data
|
||||||
|
)
|
||||||
|
|
||||||
outputs = await graph.run(inputs)
|
outputs = await graph.run(inputs)
|
||||||
if session_id and session_service:
|
if session_id and session_service:
|
||||||
session_service.update_session(session_id, (graph, artifacts))
|
session_service.update_session(session_id, (graph, artifacts))
|
||||||
return outputs
|
return outputs, session_id
|
||||||
|
|
||||||
|
|
||||||
def validate_input(
|
def validate_input(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue