Use cache when rerunning to allow pinned components
This commit is contained in:
parent
5784940528
commit
71c94f85fb
1 changed files with 10 additions and 5 deletions
|
|
@ -284,11 +284,16 @@ async def get_vertices(
|
||||||
):
|
):
|
||||||
"""Check the flow_id is in the flow_data_store."""
|
"""Check the flow_id is in the flow_data_store."""
|
||||||
try:
|
try:
|
||||||
flow: Flow = session.get(Flow, flow_id)
|
# First, we need to check if the flow_id is in the cache
|
||||||
if not flow or not flow.data:
|
|
||||||
raise ValueError("Invalid flow ID")
|
if cache := chat_service.get_cache(flow_id):
|
||||||
graph = Graph.from_payload(flow.data)
|
graph = cache.get("result")
|
||||||
chat_service.set_cache(flow_id, graph)
|
else:
|
||||||
|
flow: Flow = session.get(Flow, flow_id)
|
||||||
|
if not flow or not flow.data:
|
||||||
|
raise ValueError("Invalid flow ID")
|
||||||
|
graph = Graph.from_payload(flow.data)
|
||||||
|
chat_service.set_cache(flow_id, graph)
|
||||||
|
|
||||||
if component_id:
|
if component_id:
|
||||||
vertices = graph.sort_up_to_vertex(component_id)
|
vertices = graph.sort_up_to_vertex(component_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue