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.
Following #359, this PR introduces
Select
as an alternative toCondition
when defining "one to many" transitions.Not only can this be more ergonomic for developers, it allows to resolve multiple conditions at once. This was impossible before and conditions were only binary checks evaluated sequentially.
For example, this is now a valid
Graph
definitionChanges
Select
construct.get_next_node()
and.with_transitions()
ofGraph
andGraphBuilder
to supportSelect
GraphBuilder()
andApplicationBuilder()
type annotations to receiveSelect
GraphBuilder()
andApplicationBuilder()
type annotations to useSequence
instead ofList
How I tested this
Select
objects and call the.run()
methodPotential TODOs
default
kwarg toSelect
. This could be the defaultAction
to use if theresolver
returnsNone
for instanceresolver
to directly return anAction
or an integer index of the action instead ofaction_name: str
Select.resolver
because it currently dislikes user-provided functions annotated withlist
instead ofSequence
TODOs
Select
to the main docsSelect
? Should I update.with_transitions()
of other objects?)examples/
that uses an LLM to decide the next action (see 1-to-many transitions #359)Checklist