mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-03 08:18:47 +02:00
adding tutorials to notebook checks (#1747)
* wip * actually catch errors * fixing tool-calling-errors and persistence-redis * poetry changes * poetry update * run tutorials * only tutorials (testing) * print errors * rewoo fixes * remove customer support because of user input * skip notebooks programatically * add back how-tos * remove redundant if * add cassetes for tutorials * remove no execution since it is generated by CI, * remove multi-agent/usaco * try to run in parallel * skip notebooks fix * remove magic/non-magic cells * msgpack instead of yaml * prepare_notebooks change * ignore msgpack for spelling * use compression for cassettes * update spell check * reset poetry changes * upgrade packages for latest * no update * poetry changes
This commit is contained in:
@@ -257,7 +257,7 @@
|
||||
" }\n",
|
||||
"\n",
|
||||
" checkpoint = serde.loads_typed(\n",
|
||||
" (data[b\"type\"].decode(), data[b\"checkpoint\"].decode())\n",
|
||||
" (data[b\"type\"].decode(), data[b\"checkpoint\"])\n",
|
||||
" )\n",
|
||||
" metadata = serde.loads(data[b\"metadata\"].decode())\n",
|
||||
" parent_checkpoint_id = data.get(b\"parent_checkpoint_id\", b\"\").decode()\n",
|
||||
|
||||
@@ -208,12 +208,12 @@
|
||||
"text": [
|
||||
"HUMAN: what is the weather in san francisco?\n",
|
||||
"\n",
|
||||
"AI: [{'id': 'toolu_01VjsFXhm1UhMjPJdR4UFQDJ', 'input': {'location': 'san francisco'}, 'name': 'get_weather', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'id': 'toolu_01K5tXKVRbETcs7Q8U9PHy96', 'input': {'location': 'san francisco'}, 'name': 'get_weather', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: Error: ValueError('Input queries must be proper nouns')\n",
|
||||
" Please fix your mistakes.\n",
|
||||
"\n",
|
||||
"AI: [{'text': 'Apologies, it looks like there was an issue with the weather lookup. Let me try that again with the proper format:', 'type': 'text'}, {'id': 'toolu_016t7msu5sQiDXrTWkoM2GBG', 'input': {'location': 'San Francisco'}, 'name': 'get_weather', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'text': 'Apologies, it looks like there was an issue with the weather lookup. Let me try that again with the proper format:', 'type': 'text'}, {'id': 'toolu_01KSCsme3Du2NBazSJQ1af4b', 'input': {'location': 'San Francisco'}, 'name': 'get_weather', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: It's 60 degrees and foggy.\n",
|
||||
"\n",
|
||||
@@ -245,7 +245,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -254,7 +254,7 @@
|
||||
"text": [
|
||||
"HUMAN: Write me an incredible haiku about water.\n",
|
||||
"\n",
|
||||
"AI: [{'text': 'Here is a haiku about water:', 'type': 'text'}, {'id': 'toolu_01GVD3wqdwzFQc1Hit7UzHSt', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'text': 'Here is a haiku about water:', 'type': 'text'}, {'id': 'toolu_01L13Z3Gtaym5KKgPXVyZhYn', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: Error: 1 validation error for master_haiku_generator\n",
|
||||
"request\n",
|
||||
@@ -262,7 +262,7 @@
|
||||
" For further information visit https://errors.pydantic.dev/2.7/v/missing\n",
|
||||
" Please fix your mistakes.\n",
|
||||
"\n",
|
||||
"AI: [{'text': 'Oops, my apologies. Let me try that again with the correct format:', 'type': 'text'}, {'id': 'toolu_01Wj9ocQBPUrS9voHb2raqwx', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'text': 'Oops, my apologies. Let me try that again with the correct format:', 'type': 'text'}, {'id': 'toolu_01HCQ5uXr5kXQHBQ3FyQ1Ysk', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: Error: 1 validation error for master_haiku_generator\n",
|
||||
"request\n",
|
||||
@@ -270,7 +270,7 @@
|
||||
" For further information visit https://errors.pydantic.dev/2.7/v/missing\n",
|
||||
" Please fix your mistakes.\n",
|
||||
"\n",
|
||||
"AI: [{'text': 'Hmm, it seems there was an issue with the input format. Let me try a different approach:', 'type': 'text'}, {'id': 'toolu_01WfwAU9nxnoBh6HEboBPrxM', 'input': {'request': {'topic': ['water']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'text': 'Hmm, it seems there was an issue with the input format. Let me try a different approach:', 'type': 'text'}, {'id': 'toolu_01RF96nruwr4nMqhLBRsbfE5', 'input': {'request': {'topic': ['water']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: Error: 1 validation error for master_haiku_generator\n",
|
||||
"request.topic\n",
|
||||
@@ -278,7 +278,7 @@
|
||||
" For further information visit https://errors.pydantic.dev/2.7/v/too_short\n",
|
||||
" Please fix your mistakes.\n",
|
||||
"\n",
|
||||
"AI: [{'text': 'Ah I see, the haiku generator requires at least 3 topics. Let me provide 3 topics related to water:', 'type': 'text'}, {'id': 'toolu_014M2beHCGvNSz6FSmnunUUG', 'input': {'request': {'topic': ['ocean', 'rain', 'river']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"AI: [{'text': 'Ah I see, the haiku generator requires at least 3 topics. Let me provide 3 topics related to water:', 'type': 'text'}, {'id': 'toolu_011jcgHuG2Kyr87By459huqQ', 'input': {'request': {'topic': ['ocean', 'rain', 'river']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}]\n",
|
||||
"\n",
|
||||
"TOOL: Here is a haiku about ocean, rain, and river:\n",
|
||||
"\n",
|
||||
@@ -293,10 +293,14 @@
|
||||
],
|
||||
"source": [
|
||||
"from langchain_core.output_parsers import StrOutputParser\n",
|
||||
"from pydantic import BaseModel, Field\n",
|
||||
"\n",
|
||||
"from pydantic import BaseModel, conlist\n",
|
||||
"class HaikuRequest(BaseModel):\n",
|
||||
" topic: conlist(str, min_length=3, max_length=3)\n",
|
||||
" topic: list[str] = Field(\n",
|
||||
" max_length=3,\n",
|
||||
" min_length=3,\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@tool\n",
|
||||
@@ -365,7 +369,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -499,7 +503,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -530,19 +534,19 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'agent': {'messages': [AIMessage(content=[{'text': 'Here is a haiku about water:', 'type': 'text'}, {'id': 'toolu_01KTUs6ctRCq16sq9sgQv3wv', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}], additional_kwargs={}, response_metadata={'id': 'msg_016PcwaodGvp1mfg5Y2zCZdY', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 384, 'output_tokens': 67}}, id='run-b07f1a34-03f1-45eb-be6c-cb8fa9f40ae8-0', tool_calls=[{'name': 'master_haiku_generator', 'args': {'topic': ['water']}, 'id': 'toolu_01KTUs6ctRCq16sq9sgQv3wv', 'type': 'tool_call'}], usage_metadata={'input_tokens': 384, 'output_tokens': 67, 'total_tokens': 451})]}}\n",
|
||||
"{'tools': {'messages': [ToolMessage(content='', name='master_haiku_generator', id='9f17c76c-cd1f-46af-ae9f-a751870e9623', tool_call_id='toolu_01KTUs6ctRCq16sq9sgQv3wv')]}}\n",
|
||||
"{'remove_failed_tool_call_attempt': {'messages': [RemoveMessage(content='', additional_kwargs={}, response_metadata={}, id='run-b07f1a34-03f1-45eb-be6c-cb8fa9f40ae8-0'), RemoveMessage(content='', additional_kwargs={}, response_metadata={}, id='9f17c76c-cd1f-46af-ae9f-a751870e9623')]}}\n",
|
||||
"{'fallback_agent': {'messages': [AIMessage(content=[{'text': 'Certainly! I\\'d be happy to help you create an incredible haiku about water. To do this, I\\'ll use the master_haiku_generator function, which requires three topics. Since you\\'ve specified water as the main theme, I\\'ll add two related concepts to create a more vivid and interesting haiku. Let\\'s use \"water,\" \"flow,\" and \"reflection\" as our three topics.', 'type': 'text'}, {'id': 'toolu_01Aaw1k5JoAFvW4qhXZp6d8R', 'input': {'request': {'topic': ['water', 'flow', 'reflection']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}], additional_kwargs={}, response_metadata={'id': 'msg_01TYGeG6NDCRDY362fzWBuHc', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 414, 'output_tokens': 158}}, id='run-cd0145ce-c7b9-42cc-8ef7-ed31e43ae2cd-0', tool_calls=[{'name': 'master_haiku_generator', 'args': {'request': {'topic': ['water', 'flow', 'reflection']}}, 'id': 'toolu_01Aaw1k5JoAFvW4qhXZp6d8R', 'type': 'tool_call'}], usage_metadata={'input_tokens': 414, 'output_tokens': 158, 'total_tokens': 572})]}}\n",
|
||||
"{'tools': {'messages': [ToolMessage(content='\"Here is a haiku about water, flow, and reflection:\\\\n\\\\nRippling waters flow,\\\\nMirroring the sky above,\\\\nTranquil reflection.\"', name='master_haiku_generator', id='fd0b83d7-1689-4ae8-8b96-efc6312b9728', tool_call_id='toolu_01Aaw1k5JoAFvW4qhXZp6d8R')]}}\n",
|
||||
"{'agent': {'messages': [AIMessage(content='I hope you enjoy this haiku about the beauty and serenity of water. Please let me know if you would like me to generate another one.', additional_kwargs={}, response_metadata={'id': 'msg_01VVhnkp81jmo6DhiL4GEVzx', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'input_tokens': 587, 'output_tokens': 35}}, id='run-437ce9bb-94fc-4bdd-98ee-09175ffb580c-0', usage_metadata={'input_tokens': 587, 'output_tokens': 35, 'total_tokens': 622})]}}\n"
|
||||
"{'agent': {'messages': [AIMessage(content=[{'text': 'Here is a haiku about water:', 'type': 'text'}, {'id': 'toolu_019mY8NX4t7YkJBWeHG6jE4T', 'input': {'topic': ['water']}, 'name': 'master_haiku_generator', 'type': 'tool_use'}], additional_kwargs={}, response_metadata={'id': 'msg_01RmoaLh38DnRX2fv7E8vCFh', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 384, 'output_tokens': 67}}, id='run-a1511215-1a62-49b5-b5b3-b2c8f8c7920e-0', tool_calls=[{'name': 'master_haiku_generator', 'args': {'topic': ['water']}, 'id': 'toolu_019mY8NX4t7YkJBWeHG6jE4T', 'type': 'tool_call'}], usage_metadata={'input_tokens': 384, 'output_tokens': 67, 'total_tokens': 451})]}}\n",
|
||||
"{'tools': {'messages': [ToolMessage(content='', name='master_haiku_generator', id='69f85339-dbc2-4341-8c4d-26300dfe31a5', tool_call_id='toolu_019mY8NX4t7YkJBWeHG6jE4T')]}}\n",
|
||||
"{'remove_failed_tool_call_attempt': {'messages': [RemoveMessage(content='', additional_kwargs={}, response_metadata={}, id='run-a1511215-1a62-49b5-b5b3-b2c8f8c7920e-0'), RemoveMessage(content='', additional_kwargs={}, response_metadata={}, id='69f85339-dbc2-4341-8c4d-26300dfe31a5')]}}\n",
|
||||
"{'fallback_agent': {'messages': [AIMessage(content=[{'text': 'Certainly! I\\'d be happy to help you create an incredible haiku about water. To do this, I\\'ll use the master_haiku_generator function, which requires three topics. Since you\\'ve specified water as the main theme, I\\'ll add two related concepts to create a more vivid and interesting haiku. Let\\'s use \"water,\" \"flow,\" and \"reflection\" as our three topics.', 'type': 'text'}, {'id': 'toolu_01FxSxy8LeQ5PjdNYq8vLFTd', 'input': {'request': {'topic': ['water', 'flow', 'reflection']}}, 'name': 'master_haiku_generator', 'type': 'tool_use'}], additional_kwargs={}, response_metadata={'id': 'msg_01U5HV3pt1NVm6syGbxx29no', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 414, 'output_tokens': 158}}, id='run-3eb746c7-b607-4ad3-881a-1c11a7638af7-0', tool_calls=[{'name': 'master_haiku_generator', 'args': {'request': {'topic': ['water', 'flow', 'reflection']}}, 'id': 'toolu_01FxSxy8LeQ5PjdNYq8vLFTd', 'type': 'tool_call'}], usage_metadata={'input_tokens': 414, 'output_tokens': 158, 'total_tokens': 572})]}}\n",
|
||||
"{'tools': {'messages': [ToolMessage(content='\"Here is a haiku about water, flow, and reflection:\\\\n\\\\nRippling waters flow,\\\\nMirroring the sky above,\\\\nTranquil reflection.\"', name='master_haiku_generator', id='fdfc497d-939a-42c0-8748-31371b98a3a7', tool_call_id='toolu_01FxSxy8LeQ5PjdNYq8vLFTd')]}}\n",
|
||||
"{'agent': {'messages': [AIMessage(content='I hope you enjoy this haiku about the beauty and serenity of water. Please let me know if you would like me to generate another one.', additional_kwargs={}, response_metadata={'id': 'msg_012rXWHapc8tPfBPEonpAT6W', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'input_tokens': 587, 'output_tokens': 35}}, id='run-ab6d412d-9374-4a4b-950d-6dcc43d87cf5-0', usage_metadata={'input_tokens': 587, 'output_tokens': 35, 'total_tokens': 622})]}}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"%pip install -U langgraph langsmith\n",
|
||||
"\n",
|
||||
"# Used for this tutorial; not a requirement for LangGraph\n",
|
||||
"%pip install -U langchain_anthropic"
|
||||
]
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -52,7 +52,6 @@
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"%pip install -U langchain_community langchain_openai langgraph wikipedia scikit-learn langchain_fireworks\n",
|
||||
"# We use one or the other search engine below\n",
|
||||
"%pip install -U duckduckgo tavily-python"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
"source": [
|
||||
"%%capture --no-stderr\n",
|
||||
"%pip install -U langgraph langchain_anthropic langsmith\n",
|
||||
"# For the embedding-based classifier use in phase 2\n",
|
||||
"%pip install -U sklearn langchain_openai"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user