docs: how-to fix some issues (#1983)

Fixes some issues introduced while updating how-to docs
This commit is contained in:
Eugene Yurtsev
2024-10-02 22:06:03 +00:00
committed by GitHub
parent 86edf631e3
commit d683630094
6 changed files with 46 additions and 24 deletions
+2 -2
View File
@@ -18,8 +18,8 @@
" </a>\n",
" </li>\n",
" <li>\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/high_level/\">\n",
" LangGraph Concepts\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/low_level/\">\n",
" LangGraph Glossary\n",
" </a>\n",
" </li>\n",
" <li>\n",
+12 -3
View File
@@ -18,15 +18,24 @@
" This guide assumes familiarity with the following:\n",
" <ul>\n",
" <li>\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/high_level/\">\n",
" LangGraph Concepts\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/low_level/#nodes\">\n",
" Node\n",
" </a>\n",
" </li>\n",
" <li>\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/low_level/#edges\">\n",
" Edge\n",
" </a>\n",
" </li> \n",
" <li>\n",
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/low_level/#reducers\">\n",
" Reducer\n",
" </a>\n",
" </li>\n",
" </ul>\n",
" </p>\n",
"</div> \n",
"\n",
"\n",
"Parallel execution of nodes is essential to speed up overall graph operation. LangGraph offers native support for parallel execution of nodes, which can significantly enhance the performance of graph-based workflows. This parallelization is achieved through fan-out and fan-in mechanisms, utilizing both standard edges and [conditional_edges](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.MessageGraph.add_conditional_edges). Below are some examples showing how to add create branching dataflows that work for you. \n",
"\n",
"![Screenshot 2024-07-09 at 2.55.56 PM.png](attachment:51f122de-b2ce-4c21-a5a7-c3be70c28a91.png)"
@@ -151,14 +151,6 @@
"print()\n",
"print(f\"Output of graph invocation: {response}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ce80b5c-73cc-4f78-9d14-26c4ba46f478",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
+8 -1
View File
@@ -30,9 +30,16 @@
"\n",
"This reference implementation shows how to use MongoDB as the backend for persisting checkpoint state. Make sure that you have MongoDB running on port `27017` for going through this guide.\n",
"\n",
"NOTE: this is just an reference implementation. You can implement your own checkpointer using a different database or modify this one as long as it conforms to the `BaseCheckpointSaver` interface.\n",
"<div class=\"admonition tip\">\n",
" <p class=\"admonition-title\">Note</p>\n",
" <p>\n",
" This is a **reference** implementation. You can implement your own checkpointer using a different database or modify this one as long as it conforms to the <a href=\"https://langchain-ai.github.io/langgraph/reference/checkpoints/#langgraph.checkpoint.base.BaseCheckpointSaver\">BaseCheckpointSaver</a> interface.\n",
" </p>\n",
"</div>\n",
"\n",
"For demonstration purposes we add persistence to the [pre-built create react agent](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent), but you can add a checkpointer to any custom graph that you build.\n",
"\n",
"## TLDR\n",
" \n",
"```python\n",
"from langgraph.graph import StateGraph\n",
+9 -5
View File
@@ -16,7 +16,7 @@
" <a href=\"https://langchain-ai.github.io/langgraph/concepts/persistence/\">\n",
" Persistence\n",
" </a>\n",
" </li> \n",
" </li>\n",
" <li>\n",
" <a href=\"https://redis.io/\">\n",
" Redis\n",
@@ -30,8 +30,12 @@
"\n",
"This reference implementation shows how to use Redis as the backend for persisting checkpoint state. Make sure that you have Redis running on port `6379` for going through this guide.\n",
"\n",
"NOTE: this is just an reference implementation. You can implement your own checkpointer using a different database or modify this one as long as it conforms to the `BaseCheckpointSaver` interface.\n",
"\n",
"<div class=\"admonition tip\">\n",
" <p class=\"admonition-title\">Note</p>\n",
" <p>\n",
" This is a **reference** implementation. You can implement your own checkpointer using a different database or modify this one as long as it conforms to the <a href=\"https://langchain-ai.github.io/langgraph/reference/checkpoints/#langgraph.checkpoint.base.BaseCheckpointSaver\">BaseCheckpointSaver</a> interface.\n",
" </p>\n",
"</div>\n",
"\n",
"For demonstration purposes we add persistence to the [pre-built create react agent](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent), but you can add a checkpointer to any custom graph that you build.\n",
"\n",
@@ -41,7 +45,7 @@
"\n",
"builder = StateGraph(....)\n",
"# ... define the graph\n",
"checkpointer = # mongodb checkpointer (see examples below)\n",
"checkpointer = # redis checkpointer (see examples below)\n",
"graph = builder.compile(checkpointer=checkpointer)\n",
"...\n",
"```"
@@ -1037,7 +1041,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.4"
}
},
"nbformat": 4,
+15 -5
View File
@@ -25,7 +25,7 @@
" <li>\n",
" <a href=\"https://github.com/pydantic/pydantic\">\n",
" Pydantic\n",
" </a> -- this is a very popular Python library for run time validation.\n",
" </a>: this is a popular Python library for run time validation.\n",
" </li>\n",
" </ul>\n",
" </p>\n",
@@ -41,10 +41,20 @@
"<div class=\"admonition note\">\n",
" <p class=\"admonition-title\">Known Limitations</p>\n",
" <p>\n",
" * This notebook uses Pydantic v2 <code>BaseModel</code>, which requires <code>langchain-core >= 0.3</code>. Using <code>langchain-core < 0.3</code> will result in errors due to mixing of Pydantic v1 and v2 <code>BaseModels</code>.\n",
" * Currently, the `output` of the graph will **NOT** be an instance of a pydantic model.\n",
" * Run-time validation only occurs on **inputs** into nodes, not on the outputs.\n",
" * The validation error trace from pydantic does not show which node the error arises in.\n",
" <ul>\n",
" <li>\n",
" This notebook uses Pydantic v2 <code>BaseModel</code>, which requires <code>langchain-core >= 0.3</code>. Using <code>langchain-core < 0.3</code> will result in errors due to mixing of Pydantic v1 and v2 <code>BaseModels</code>. \n",
" </li> \n",
" <li>\n",
" Currently, the `output` of the graph will **NOT** be an instance of a pydantic model.\n",
" </li>\n",
" <li>\n",
" Run-time validation only occurs on **inputs** into nodes, not on the outputs.\n",
" </li>\n",
" <li>\n",
" The validation error trace from pydantic does not show which node the error arises in.\n",
" </li>\n",
" </ul>\n",
" </p>\n",
"</div>"
]