Shorten conditional edge names

This commit is contained in:
Nuno Campos
2024-04-12 09:29:27 -07:00
parent dfec700da8
commit f3ae555b91
5 changed files with 622 additions and 586 deletions
File diff suppressed because one or more lines are too long
-1
View File
@@ -355,7 +355,6 @@ class CompiledGraph(Pregel):
graph.add_edge(start_nodes[start], end_nodes[end])
for start, branches in self.graph.branches.items():
for name, branch in branches.items():
name = f"{start}_{name}"
cond = graph.add_node(branch.condition, name)
graph.add_edge(start_nodes[start], cond)
ends = branch.ends or {
File diff suppressed because it is too large Load Diff
+66 -66
View File
@@ -3086,39 +3086,39 @@ def test_in_one_fan_out_state_graph_waiting_edge_via_branch(
app = workflow.compile()
assert app.get_graph().draw_ascii() == (
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
** **
** **
** **
+--------------+ +-------------------------+
| analyzer_one | | rewrite_query_condition |
+--------------+ +-------------------------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
** **
** **
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
*** ***
* *
** **
+--------------+ +-----------+
| analyzer_one | | condition |
+--------------+ +-----------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
*** ***
* *
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
)
assert app.invoke({"query": "what is weather in sf"}, debug=True) == {
@@ -3220,39 +3220,39 @@ def test_in_one_fan_out_state_graph_waiting_edge_custom_state_class(
app = workflow.compile()
assert app.get_graph().draw_ascii() == (
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
** **
** **
** **
+--------------+ +-----------------------+
| analyzer_one | | rewrite_query_decider |
+--------------+ +-----------------------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
** **
** **
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
*** ***
* *
** **
+--------------+ +---------+
| analyzer_one | | decider |
+--------------+ +---------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
*** ***
* *
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
)
with pytest.raises(ValidationError):
+66 -66
View File
@@ -2825,39 +2825,39 @@ async def test_in_one_fan_out_state_graph_waiting_edge_via_branch(
app = workflow.compile()
assert app.get_graph().draw_ascii() == (
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
** **
** **
** **
+--------------+ +-------------------------+
| analyzer_one | | rewrite_query_condition |
+--------------+ +-------------------------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
** **
** **
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
*** ***
* *
** **
+--------------+ +-----------+
| analyzer_one | | condition |
+--------------+ +-----------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
*** ***
* *
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
)
assert await app.ainvoke({"query": "what is weather in sf"}, debug=True) == {
@@ -2962,39 +2962,39 @@ async def test_in_one_fan_out_state_graph_waiting_edge_custom_state_class(
app = workflow.compile()
assert app.get_graph().draw_ascii() == (
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
** **
** **
** **
+--------------+ +-----------------------+
| analyzer_one | | rewrite_query_decider |
+--------------+ +-----------------------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
** **
** **
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
""" +-----------+
| __start__ |
+-----------+
*
*
*
+---------------+
| rewrite_query |
+---------------+
*** ***
* *
** **
+--------------+ +---------+
| analyzer_one | | decider |
+--------------+ +---------+
* *
* *
* *
+---------------+ +---------------+
| retriever_one | | retriever_two |
+---------------+ +---------------+
*** ***
* *
** **
+----+
| qa |
+----+
*
*
*
+---------+
| __end__ |
+---------+ """
)
with pytest.raises(ValidationError):