mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-28 12:35:08 +02:00
[Docs] use END instead of set_finish_point (#903)
This commit is contained in:
@@ -119,6 +119,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langgraph_sdk import get_client\n",
|
||||
"\n",
|
||||
"client = get_client()"
|
||||
]
|
||||
},
|
||||
@@ -354,7 +355,9 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's the weather in sf\")]}\n",
|
||||
"async for chunk in client.runs.stream(None, \"agent\", input=inputs, stream_mode=\"values\"):\n",
|
||||
"async for chunk in client.runs.stream(\n",
|
||||
" None, \"agent\", input=inputs, stream_mode=\"values\"\n",
|
||||
"):\n",
|
||||
" if chunk.event == \"values\":\n",
|
||||
" messages = convert_to_messages(chunk.data[\"messages\"])\n",
|
||||
" messages[-1].pretty_print()"
|
||||
@@ -423,7 +426,9 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's the weather in nyc\")]}\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(inputs, config={\"configurable\": {\"thread_id\": \"1\"}})\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(\n",
|
||||
" inputs, config={\"configurable\": {\"thread_id\": \"1\"}}\n",
|
||||
")\n",
|
||||
"invoke_output[\"messages\"][-1].pretty_print()"
|
||||
]
|
||||
},
|
||||
@@ -458,7 +463,9 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's it known for?\")]}\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(inputs, config={\"configurable\": {\"thread_id\": \"1\"}})\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(\n",
|
||||
" inputs, config={\"configurable\": {\"thread_id\": \"1\"}}\n",
|
||||
")\n",
|
||||
"invoke_output[\"messages\"][-1].pretty_print()"
|
||||
]
|
||||
},
|
||||
@@ -480,7 +487,9 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's it known for?\")]}\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(inputs, config={\"configurable\": {\"thread_id\": \"2\"}})\n",
|
||||
"invoke_output = await graph_with_memory.ainvoke(\n",
|
||||
" inputs, config={\"configurable\": {\"thread_id\": \"2\"}}\n",
|
||||
")\n",
|
||||
"invoke_output[\"messages\"][-1].pretty_print()"
|
||||
]
|
||||
},
|
||||
@@ -724,7 +733,12 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's the weather in sf\")]}\n",
|
||||
"async for chunk in graph_with_memory.astream(inputs, stream_mode=\"values\", interrupt_before=[\"tools\"], config={\"configurable\": {\"thread_id\": \"3\"}}):\n",
|
||||
"async for chunk in graph_with_memory.astream(\n",
|
||||
" inputs,\n",
|
||||
" stream_mode=\"values\",\n",
|
||||
" interrupt_before=[\"tools\"],\n",
|
||||
" config={\"configurable\": {\"thread_id\": \"3\"}},\n",
|
||||
"):\n",
|
||||
" chunk[\"messages\"][-1].pretty_print()"
|
||||
]
|
||||
},
|
||||
@@ -749,7 +763,12 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"async for chunk in graph_with_memory.astream(None, stream_mode=\"values\", interrupt_before=[\"tools\"], config={\"configurable\": {\"thread_id\": \"3\"}}):\n",
|
||||
"async for chunk in graph_with_memory.astream(\n",
|
||||
" None,\n",
|
||||
" stream_mode=\"values\",\n",
|
||||
" interrupt_before=[\"tools\"],\n",
|
||||
" config={\"configurable\": {\"thread_id\": \"3\"}},\n",
|
||||
"):\n",
|
||||
" chunk[\"messages\"][-1].pretty_print()"
|
||||
]
|
||||
},
|
||||
@@ -794,7 +813,13 @@
|
||||
"source": [
|
||||
"thread = await client.threads.create()\n",
|
||||
"\n",
|
||||
"async for chunk in client.runs.stream(thread[\"thread_id\"], \"agent\", input=inputs, stream_mode=\"values\", interrupt_before=[\"tools\"]):\n",
|
||||
"async for chunk in client.runs.stream(\n",
|
||||
" thread[\"thread_id\"],\n",
|
||||
" \"agent\",\n",
|
||||
" input=inputs,\n",
|
||||
" stream_mode=\"values\",\n",
|
||||
" interrupt_before=[\"tools\"],\n",
|
||||
"):\n",
|
||||
" if chunk.event == \"values\":\n",
|
||||
" messages = convert_to_messages(chunk.data[\"messages\"])\n",
|
||||
" messages[-1].pretty_print()"
|
||||
@@ -821,7 +846,13 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"async for chunk in client.runs.stream(thread[\"thread_id\"], \"agent\", input=None, stream_mode=\"values\", interrupt_before=[\"tools\"]):\n",
|
||||
"async for chunk in client.runs.stream(\n",
|
||||
" thread[\"thread_id\"],\n",
|
||||
" \"agent\",\n",
|
||||
" input=None,\n",
|
||||
" stream_mode=\"values\",\n",
|
||||
" interrupt_before=[\"tools\"],\n",
|
||||
"):\n",
|
||||
" if chunk.event == \"values\":\n",
|
||||
" messages = convert_to_messages(chunk.data[\"messages\"])\n",
|
||||
" messages[-1].pretty_print()"
|
||||
@@ -1000,7 +1031,9 @@
|
||||
],
|
||||
"source": [
|
||||
"inputs = {\"messages\": [(\"human\", \"what's the weather in sf\")]}\n",
|
||||
"async for chunk in client.runs.stream(None, \"agent\", input=inputs, stream_mode=\"events\"):\n",
|
||||
"async for chunk in client.runs.stream(\n",
|
||||
" None, \"agent\", input=inputs, stream_mode=\"events\"\n",
|
||||
"):\n",
|
||||
" if chunk.event == \"events\" and chunk.data[\"event\"] == \"on_chat_model_stream\":\n",
|
||||
" print(chunk.data[\"data\"][\"chunk\"])"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user