mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-25 09:02:25 +02:00
add back graph.update_line, update output (#1887)
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -126,7 +126,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -179,7 +179,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -209,7 +209,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -217,7 +217,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'router_node': {'route': 'other'}}\n",
|
||||
"{'normal_llm_node': {'messages': [AIMessage(content='Hello! How can I assist you today?', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 9, 'total_tokens': 18, 'completion_tokens_details': {'reasoning_tokens': 0}}, 'model_name': 'gpt-3.5-turbo-0125', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-6405070a-cf4c-4a6a-a1d6-7b444edbb64f-0', usage_metadata={'input_tokens': 9, 'output_tokens': 9, 'total_tokens': 18})]}}\n"
|
||||
"{'normal_llm_node': {'messages': [AIMessage(content='Hello! How can I assist you today?', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 9, 'prompt_tokens': 9, 'total_tokens': 18, 'completion_tokens_details': {'reasoning_tokens': 0}}, 'model_name': 'gpt-3.5-turbo-0125', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-35de4577-2117-40e4-ab3b-cd2ac6e27b4c-0', usage_metadata={'input_tokens': 9, 'output_tokens': 9, 'total_tokens': 18})]}}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -241,7 +241,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -510,7 +510,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -619,7 +619,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -627,17 +627,14 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"((), {'router_node': {'route': 'weather'}})\n",
|
||||
"HERE\n",
|
||||
"(('weather_graph:ec34ba77-edd8-bbf1-f3f1-01498cf0c575',), {'model_node': {'city': 'San Francisco'}})\n",
|
||||
"(('weather_graph:c7eb1fc7-efab-b0e3-12ed-8586f37bc7a2',), {'model_node': {'city': 'San Francisco'}})\n",
|
||||
"interrupted!\n",
|
||||
"(('weather_graph:ec34ba77-edd8-bbf1-f3f1-01498cf0c575',), {'weather_node': {'messages': [{'role': 'assistant', 'content': \"It's sunny in San Francisco!\"}]}})\n",
|
||||
"((), {'weather_graph': {'messages': [HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='c94dd545-308d-4032-832a-57aab1abb6b1'), AIMessage(content=\"It's sunny in San Francisco!\", additional_kwargs={}, response_metadata={}, id='9d004035-5ffe-4b44-addc-4f0d61255f16')]}})\n",
|
||||
"[HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='c94dd545-308d-4032-832a-57aab1abb6b1'), AIMessage(content=\"It's sunny in San Francisco!\", additional_kwargs={}, response_metadata={}, id='9d004035-5ffe-4b44-addc-4f0d61255f16')]\n"
|
||||
"((), {'weather_graph': {'messages': [HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='ad694c4e-8aac-4e1f-b5ca-790c60c1775b'), AIMessage(content='rainy', additional_kwargs={}, response_metadata={}, id='98a73aaf-3524-482a-9d07-971407df0389')]}})\n",
|
||||
"[HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='ad694c4e-8aac-4e1f-b5ca-790c60c1775b'), AIMessage(content='rainy', additional_kwargs={}, response_metadata={}, id='98a73aaf-3524-482a-9d07-971407df0389')]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"graph = \n",
|
||||
"config = {\"configurable\": {\"thread_id\": \"14\"}}\n",
|
||||
"inputs = {\"messages\": [{\"role\": \"user\", \"content\": \"what's the weather in sf\"}]}\n",
|
||||
"for update in graph.stream(inputs, config=config, stream_mode=\"updates\", subgraphs=True):\n",
|
||||
@@ -646,7 +643,7 @@
|
||||
"print(\"interrupted!\")\n",
|
||||
"state = graph.get_state(config, subgraphs=True)\n",
|
||||
"# We update the state by passing in the message we want returned from the weather node, and make sure to use as_node\n",
|
||||
"#graph.update_state(state.tasks[0].state.config, {\"messages\": [{\"role\": \"assistant\", \"content\": \"rainy\"}]}, as_node=\"weather_node\")\n",
|
||||
"graph.update_state(state.tasks[0].state.config, {\"messages\": [{\"role\": \"assistant\", \"content\": \"rainy\"}]}, as_node=\"weather_node\")\n",
|
||||
"for update in graph.stream(None, config=config, stream_mode=\"updates\", subgraphs=True):\n",
|
||||
" print(update)\n",
|
||||
"print(graph.get_state(config).values['messages'])"
|
||||
|
||||
Reference in New Issue
Block a user