Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new streaming feature to the ControlFlow library, allowing for real-time processing of events during task execution. It also includes significant updates to the documentation and several codebase improvements to support this new functionality.
To automatically filter for common event types, use the stream flags
New Streaming Feature:
docs/patterns/running-tasks.mdx
: Added a new section on streaming, explaining how to enable and use the streaming feature in ControlFlow.docs/patterns/streaming-tasks.mdx
: Created a new document detailing the streaming feature, including examples and explanations of different event types and handlers.src/controlflow/__init__.py
: Exported theStream
class from therun
module to make it available for import.Codebase Enhancements:
src/controlflow/agents/agent.py
: Updated therun
andrun_async
methods to support the newstream
parameter, allowing tasks to be executed with streaming enabled. [1] [2]src/controlflow/events/events.py
: Modified methods to handle optional content and content deltas, ensuring they only return events when content is present. [1] [2]Documentation Updates:
docs/mint.json
: Added the newpatterns/streaming-tasks
document to the list of documentation patterns.Event Handling Improvements:
src/controlflow/events/orchestrator_events.py
: Added orchestrator event definitions to handle the start and end of orchestration processes.src/controlflow/events/task_events.py
: Added task event definitions to handle various task lifecycle events such as start, success, failure, and skipped.These changes collectively enhance the ControlFlow library by introducing real-time event streaming capabilities, improving the documentation, and refining the event handling mechanisms.