core: mermaid: Render metadata key-value pairs when drawing mermaid graph (#24103)

- if node is runnable binding with metadata attached
This commit is contained in:
Nuno Campos
2024-07-11 09:22:23 -07:00
committed by GitHub
parent 1e7d8ba9a6
commit ee3fe20af4
8 changed files with 146 additions and 116 deletions

View File

@@ -58,7 +58,7 @@
"base",
"RunnableLambda"
],
"name": "RunnableLambda"
"name": "Lambda"
}
}
],
@@ -458,7 +458,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{
@@ -498,7 +498,7 @@
"base",
"RunnableLambda"
],
"name": "RunnableLambda"
"name": "Lambda"
}
},
{
@@ -511,7 +511,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{
@@ -589,7 +589,7 @@
"runnable",
"RunnablePassthrough"
],
"name": "RunnablePassthrough"
"name": "Passthrough"
}
},
{
@@ -635,7 +635,7 @@
"runnable",
"RunnablePassthrough"
],
"name": "RunnablePassthrough"
"name": "Passthrough"
}
}
],
@@ -716,7 +716,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{
@@ -756,7 +756,7 @@
"runnable",
"RunnablePassthrough"
],
"name": "RunnablePassthrough"
"name": "Passthrough"
}
},
{
@@ -769,7 +769,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{
@@ -938,7 +938,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{
@@ -1152,7 +1152,7 @@
"runnable",
"RunnableWithFallbacks"
],
"name": "RunnableWithFallbacks"
"name": "WithFallbacks"
}
},
{

View File

@@ -36,7 +36,8 @@
graph TD;
PromptInput[PromptInput]:::startclass;
PromptTemplate([PromptTemplate]):::otherclass;
FakeListLLM([FakeListLLM]):::otherclass;
FakeListLLM([<strong>FakeListLLM</strong>
key = 2]):::otherclass;
CommaSeparatedListOutputParser([CommaSeparatedListOutputParser]):::otherclass;
CommaSeparatedListOutputParserOutput[CommaSeparatedListOutputParserOutput]:::endclass;
PromptInput --> PromptTemplate;

File diff suppressed because one or more lines are too long

View File

@@ -33,7 +33,7 @@ def test_graph_sequence(snapshot: SnapshotAssertion) -> None:
prompt = PromptTemplate.from_template("Hello, {name}!")
list_parser = CommaSeparatedListOutputParser()
sequence = prompt | fake_llm | list_parser
sequence = prompt | fake_llm.with_config(metadata={"key": 2}) | list_parser
graph = sequence.get_graph()
assert graph.to_json() == {
"nodes": [