mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-31 04:09:49 +02:00
docs: use retry_policy instead of retry in docs (#4958)
This commit is contained in:
@@ -1198,7 +1198,7 @@
|
||||
"\n",
|
||||
"There are many use cases where you may wish for your node to have a custom retry policy, for example if you are calling an API, querying a database, or calling an LLM, etc. LangGraph lets you add retry policies to nodes.\n",
|
||||
"\n",
|
||||
"To configure a retry policy, pass the `retry` parameter to the [add_node](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.state.StateGraph.add_node). The `retry` parameter takes in a `RetryPolicy` named tuple object. Below we instantiate a `RetryPolicy` object with the default parameters and associate it with a node:\n",
|
||||
"To configure a retry policy, pass the `retry_policy` parameter to the [add_node](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.state.StateGraph.add_node). The `retry_policy` parameter takes in a `RetryPolicy` named tuple object. Below we instantiate a `RetryPolicy` object with the default parameters and associate it with a node:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"from langgraph.pregel import RetryPolicy\n",
|
||||
@@ -1206,7 +1206,7 @@
|
||||
"builder.add_node(\n",
|
||||
" \"node_name\",\n",
|
||||
" node_function,\n",
|
||||
" retry=RetryPolicy(),\n",
|
||||
" retry_policy=RetryPolicy(),\n",
|
||||
")\n",
|
||||
"```"
|
||||
]
|
||||
@@ -1241,7 +1241,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"id": "ad92598c-b688-42fa-aae0-9de36273d584",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -1276,9 +1276,9 @@
|
||||
"builder.add_node(\n",
|
||||
" \"query_database\",\n",
|
||||
" query_database,\n",
|
||||
" retry=RetryPolicy(retry_on=sqlite3.OperationalError),\n",
|
||||
" retry_policy=RetryPolicy(retry_on=sqlite3.OperationalError),\n",
|
||||
")\n",
|
||||
"builder.add_node(\"model\", call_model, retry=RetryPolicy(max_attempts=5))\n",
|
||||
"builder.add_node(\"model\", call_model, retry_policy=RetryPolicy(max_attempts=5))\n",
|
||||
"builder.add_edge(START, \"model\")\n",
|
||||
"builder.add_edge(\"model\", \"query_database\")\n",
|
||||
"builder.add_edge(\"query_database\", END)\n",
|
||||
@@ -3416,7 +3416,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": ".venv",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -3430,7 +3430,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.4"
|
||||
"version": "3.12.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -405,7 +405,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 46,
|
||||
"execution_count": null,
|
||||
"id": "1954a5f1-91e4-4b32-9be9-c8bc1cc43cb5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -465,7 +465,7 @@
|
||||
"\n",
|
||||
"graph_builder = StateGraph(State)\n",
|
||||
"graph_builder.add_node(\"agent\", agent)\n",
|
||||
"graph_builder.add_node(\"select_tools\", select_tools, retry=RetryPolicy(max_attempts=3))\n",
|
||||
"graph_builder.add_node(\"select_tools\", select_tools, retry_policy=RetryPolicy(max_attempts=3))\n",
|
||||
"\n",
|
||||
"tool_node = ToolNode(tools=tools)\n",
|
||||
"graph_builder.add_node(\"tools\", tool_node)\n",
|
||||
|
||||
@@ -321,7 +321,7 @@ attempts = 0
|
||||
# The default RetryPolicy is optimized for retrying specific network errors.
|
||||
retry_policy = RetryPolicy(retry_on=ValueError)
|
||||
|
||||
@task(retry=retry_policy)
|
||||
@task(retry_policy=retry_policy)
|
||||
def get_info():
|
||||
global attempts
|
||||
attempts += 1
|
||||
|
||||
Reference in New Issue
Block a user