Merge branch 'validation_fix' of personal:logspace-ai/langflow into validation_fix

This commit is contained in:
anovazzi1 2023-06-13 20:43:22 -03:00
commit 8affac1f53

View file

@ -69,6 +69,8 @@ async def stream_build(flow_id: str):
"""Stream the build process based on stored flow data.""" """Stream the build process based on stored flow data."""
async def event_stream(flow_id): async def event_stream(flow_id):
final_response = json.dumps({"end_of_stream": True})
try:
if flow_id not in flow_data_store: if flow_id not in flow_data_store:
error_message = "Invalid session ID" error_message = "Invalid session ID"
yield f"data: {json.dumps({'error': error_message})}\n\n" yield f"data: {json.dumps({'error': error_message})}\n\n"
@ -102,11 +104,13 @@ async def stream_build(flow_id: str):
"id": node.id, "id": node.id,
} }
) )
yield f"data: {response}\n\n" # SSE format yield f"data: {response}\n\n"
chat_manager.set_cache(flow_id, graph.build()) chat_manager.set_cache(flow_id, graph.build())
final_response = json.dumps({"end_of_stream": True}) except Exception:
yield f"data: {final_response}\n\n" # SSE format logger.error("Error while building the flow")
finally:
yield f"data: {final_response}\n\n"
try: try:
return StreamingResponse(event_stream(flow_id), media_type="text/event-stream") return StreamingResponse(event_stream(flow_id), media_type="text/event-stream")