Add callable condition for GraphFlow edges#6623
Conversation
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
…tions Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
…graph_visibility Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6623 +/- ##
==========================================
+ Coverage 79.69% 79.75% +0.06%
==========================================
Files 228 228
Lines 17025 17040 +15
==========================================
+ Hits 13568 13591 +23
+ Misses 3457 3449 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
victordibia
left a comment
There was a problem hiding this comment.
Thanks for the example, tested, looks good.
Should we add somewhere in the docs that serializing the graph will not include conditional functions.
graph (python)
DiGraph(nodes={'A': DiGraphNode(name='A', edges=[DiGraphEdge(target='B', condition=None, condition_function=<function <lambda> at 0x1109f5bc0>), DiGraphEdge(target='C', condition=None, condition_function=<function <lambda> at 0x1109f59e0>)], activation='all'), 'B': DiGraphNode(name='B', edges=[], activation='all'), 'C': DiGraphNode(name='C', edges=[], activation='all')}, default_start_node=None)graph.model_dump()
{'nodes': {'A': {'name': 'A',
'edges': [{'target': 'B', 'condition': None},
{'target': 'C', 'condition': None}],
'activation': 'all'},
'B': {'name': 'B', 'edges': [], 'activation': 'all'},
'C': {'name': 'C', 'edges': [], 'activation': 'all'}},
'default_start_node': None}|
what is the difference with "builder.add_conditional_edges(agent_b, {"APPROVE": agent_c, "REJECT": agent_a})" that I found in the |
I see, you added a callable condition, but how to persist the callable? |
|
It won't serialize the callable. This is the issue we can address in a future PR. |
This PR adds callable as an option to specify conditional edges in GraphFlow.