-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Implement streaming support and EventManager integration in flow execution #5460
base: main
Are you sure you want to change the base?
Conversation
…nt handling - Added EventManager import and parameter to run_graph_internal function. - Updated function call to include event_manager for improved event management during graph execution.
- Added event_manager parameter to multiple methods in the Graph class to facilitate better event management during graph execution. - Updated process and run methods to include event_manager, ensuring it is passed through to relevant function calls. - Improved documentation for methods to reflect the new event_manager parameter.
… integration - Added support for streaming responses in the simplified_run_flow endpoint, allowing real-time event handling during flow execution. - Introduced consume_and_yield and run_flow_generator functions to manage event consumption and client communication. - Integrated EventManager for enhanced event tracking, including success and error notifications. - Updated endpoint documentation to reflect new streaming capabilities and parameters. - Improved error handling and logging for better debugging and client disconnection management.
CodSpeed Performance ReportMerging #5460 will improve performances by ×2.5Comparing Summary
Benchmarks breakdown
|
Copilot
AI
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/backend/base/langflow/api/v1/endpoints.py:209
- The
event_manager
parameter should be checked forNone
before usage to avoid potential issues.
event_manager: EventManager,
logger.error(f"Error running flow: {e}") | ||
event_manager.on_error(data={"error": str(e)}) | ||
finally: | ||
await event_manager.queue.put((None, None, time.time)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time.time
function should be called as time.time()
.
await event_manager.queue.put((None, None, time.time)) | |
await event_manager.queue.put((None, None, time.time())) |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
- Removed the logging of the request object in the simplified_run_flow function to streamline logging and reduce verbosity. - This change enhances the clarity of logs by focusing on essential information during flow execution.
Good Work! I believe this may not cause any reverse compatibility issues with existing APIs ? |
This pull request introduces several enhancements to the
langflow
API, focusing on adding support for event streaming and improving flow execution telemetry. The key changes include the integration of anEventManager
for handling streaming events, updates to flow execution functions to support streaming, and the addition of new utility functions for event management.Enhancements to event streaming and telemetry:
src/backend/base/langflow/api/v1/endpoints.py
: Added theEventManager
parameter to flow execution functions (simple_run_flow
,simple_run_flow_task
,simplified_run_flow
) and implemented new asynchronous functions (consume_and_yield
,run_flow_generator
) to handle event streaming. [1] [2] [3] [4] [5] [6] [7] [8]src/backend/base/langflow/events/event_manager.py
: Added a new functioncreate_stream_tokens_event_manager
to create an event manager for streaming tokens.Updates to flow execution functions:
src/backend/base/langflow/graph/graph/base.py
: Updated_run
,arun
, andprocess
methods to include theEventManager
parameter for managing events during flow execution. [1] [2] [3] [4] [5] [6] [7] [8]src/backend/base/langflow/processing/process.py
: Updatedrun_graph_internal
function to accept theEventManager
parameter, enabling event management during graph processing. [1] [2] [3]Test it using the following script: https://gist.github.com/ogabrielluiz/150c256f2030379d94913a36817e3784