Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent-architectures/1_llm_call.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"Cat\n",
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
"\n",
"If you're interested in cats, consider visiting **Kawasaki Cat Island (Aoshima Island)** in Japan. It's renowned for its large population of friendly stray cats that roam freely, making it a paradise for cat lovers!\n"
"If you love cats, I recommend visiting Tokyo, Japan! Tokyo is home to several famous cat cafes where you can relax and enjoy the company of friendly felines. Plus, you can explore neighborhoods like Harajuku and Akihabara, which offer unique shopping and cultural experiences. Don't miss a visit to the Gotokuji Temple, known as the birthplace of the famous \"Maneki-neko\" (beckoning cat) figurine!\n"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions agent-architectures/2_1_tool_call.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"from langchain_openai import AzureChatOpenAI\n",
"from langchain_core.messages import HumanMessage, SystemMessage, ToolCall, ToolMessage\n",
"from typing import Literal\n",
"from langchain.tools import tool"
"from langchain_core.tools import tool"
]
},
{
Expand Down Expand Up @@ -202,8 +202,8 @@
"What is the weather like in NYC?\n",
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
"Tool Calls:\n",
" weather_tool (call_54y4BHhxKwF55ch3RR1FaAbn)\n",
" Call ID: call_54y4BHhxKwF55ch3RR1FaAbn\n",
" weather_tool (call_Fj4l0RvLYu9EEZfwUaUzysuT)\n",
" Call ID: call_Fj4l0RvLYu9EEZfwUaUzysuT\n",
" Args:\n",
" location: New York\n",
"=================================\u001b[1m Tool Message \u001b[0m=================================\n",
Expand All @@ -212,7 +212,7 @@
"Sunny, 25°C\n",
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
"\n",
"The weather in New York City is sunny with a temperature of 25°C. Would you like to know the weather in any other city?\n"
"The weather in New York City is currently sunny with a temperature of 25°C.\n"
]
}
],
Expand Down
30 changes: 15 additions & 15 deletions agent-architectures/2_2_react_agent.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions agent-architectures/3_routing.ipynb

Large diffs are not rendered by default.

164 changes: 131 additions & 33 deletions agent-architectures/4_reflection.ipynb

Large diffs are not rendered by default.

39 changes: 15 additions & 24 deletions agent-architectures/5_parallelism.ipynb

Large diffs are not rendered by default.

994 changes: 80 additions & 914 deletions agent-architectures/6_supervisor.ipynb

Large diffs are not rendered by default.

375 changes: 20 additions & 355 deletions agent-architectures/7_swarm.ipynb

Large diffs are not rendered by default.

53 changes: 37 additions & 16 deletions agent-architectures/8_planner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@
"execution_count": 1,
"id": "25b9ec62-0675-4715-811c-9b32c635b22f",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ValidationError",
"evalue": "1 validation error for TavilySearchAPIWrapper\n Value error, Did not find tavily_api_key, please add an environment variable `TAVILY_API_KEY` which contains it, or pass `tavily_api_key` as a named parameter. [type=value_error, input_value={}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.12/v/value_error",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mValidationError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mlangchain_tavily\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m TavilySearch\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m tavily_tool = \u001b[43mTavilySearch\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 4\u001b[39m tools = [tavily_tool]\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Desktop/Repos/presentations/.venv/lib/python3.11/site-packages/langchain_tavily/tavily_search.py:340\u001b[39m, in \u001b[36mTavilySearch.__init__\u001b[39m\u001b[34m(self, **kwargs)\u001b[39m\n\u001b[32m 337\u001b[39m wrapper_kwargs[\u001b[33m\"\u001b[39m\u001b[33mapi_base_url\u001b[39m\u001b[33m\"\u001b[39m] = kwargs[\u001b[33m\"\u001b[39m\u001b[33mapi_base_url\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m 338\u001b[39m kwargs[\u001b[33m\"\u001b[39m\u001b[33mapi_wrapper\u001b[39m\u001b[33m\"\u001b[39m] = TavilySearchAPIWrapper(**wrapper_kwargs)\n\u001b[32m--> \u001b[39m\u001b[32m340\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[34;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Desktop/Repos/presentations/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:508\u001b[39m, in \u001b[36mBaseTool.__init__\u001b[39m\u001b[34m(self, **kwargs)\u001b[39m\n\u001b[32m 503\u001b[39m msg = (\n\u001b[32m 504\u001b[39m \u001b[33m\"\u001b[39m\u001b[33margs_schema must be a subclass of pydantic BaseModel or \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 505\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33ma JSON schema dict. Got: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mkwargs[\u001b[33m'\u001b[39m\u001b[33margs_schema\u001b[39m\u001b[33m'\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 506\u001b[39m )\n\u001b[32m 507\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(msg)\n\u001b[32m--> \u001b[39m\u001b[32m508\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[34;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Desktop/Repos/presentations/.venv/lib/python3.11/site-packages/langchain_core/load/serializable.py:113\u001b[39m, in \u001b[36mSerializable.__init__\u001b[39m\u001b[34m(self, *args, **kwargs)\u001b[39m\n\u001b[32m 111\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, *args: Any, **kwargs: Any) -> \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 112\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\"\"\"\u001b[39;00m \u001b[38;5;66;03m# noqa: D419 # Intentional blank docstring\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m113\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[34;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
" \u001b[31m[... skipping hidden 1 frame]\u001b[39m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Desktop/Repos/presentations/.venv/lib/python3.11/site-packages/pydantic/main.py:250\u001b[39m, in \u001b[36mBaseModel.__init__\u001b[39m\u001b[34m(self, **data)\u001b[39m\n\u001b[32m 248\u001b[39m \u001b[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001b[39;00m\n\u001b[32m 249\u001b[39m __tracebackhide__ = \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m250\u001b[39m validated_self = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m__pydantic_validator__\u001b[49m\u001b[43m.\u001b[49m\u001b[43mvalidate_python\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mself_instance\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 251\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m validated_self:\n\u001b[32m 252\u001b[39m warnings.warn(\n\u001b[32m 253\u001b[39m \u001b[33m'\u001b[39m\u001b[33mA custom validator is returning a value other than `self`.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m'\u001b[39m\n\u001b[32m 254\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mReturning anything other than `self` from a top level model validator isn\u001b[39m\u001b[33m'\u001b[39m\u001b[33mt supported when validating via `__init__`.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 255\u001b[39m \u001b[33m'\u001b[39m\u001b[33mSee the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.\u001b[39m\u001b[33m'\u001b[39m,\n\u001b[32m 256\u001b[39m stacklevel=\u001b[32m2\u001b[39m,\n\u001b[32m 257\u001b[39m )\n",
"\u001b[31mValidationError\u001b[39m: 1 validation error for TavilySearchAPIWrapper\n Value error, Did not find tavily_api_key, please add an environment variable `TAVILY_API_KEY` which contains it, or pass `tavily_api_key` as a named parameter. [type=value_error, input_value={}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.12/v/value_error"
]
}
],
"source": [
"from langchain_tavily import TavilySearch\n",
"\n",
Expand All @@ -49,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "d2cb767c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -111,19 +128,31 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "72d233ca-1dbf-4b43-b680-b3bf39e3691f",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "NameError",
"evalue": "name 'tools' is not defined",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 8\u001b[39m\n\u001b[32m 6\u001b[39m llm = AzureChatOpenAI(model=\u001b[33m\"\u001b[39m\u001b[33mgpt-4.1-mini\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 7\u001b[39m prompt = \u001b[33m\"\u001b[39m\u001b[33mYou are a helpful assistant.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m8\u001b[39m agent_executor = create_agent(llm, \u001b[43mtools\u001b[49m, prompt=prompt)\n",
"\u001b[31mNameError\u001b[39m: name 'tools' is not defined"
]
}
],
"source": [
"from langchain_openai import AzureChatOpenAI\n",
"\n",
"from langgraph.prebuilt import create_react_agent\n",
"from langchain.agents import create_agent\n",
"\n",
"# Choose the LLM that will drive the agent\n",
"llm = AzureChatOpenAI(model=\"gpt-4.1-mini\")\n",
"prompt = \"You are a helpful assistant.\"\n",
"agent_executor = create_react_agent(llm, tools, prompt=prompt)"
"agent_executor = create_agent(llm, tools, prompt=prompt)"
]
},
{
Expand Down Expand Up @@ -458,7 +487,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "7363e528",
"metadata": {},
"outputs": [
Expand All @@ -477,7 +506,7 @@
"source": [
"from IPython.display import Image\n",
"\n",
"Image(app.get_graph().draw_mermaid_png())"
"Image(app.get_graph(xray=1).draw_mermaid_png())"
]
},
{
Expand Down Expand Up @@ -545,14 +574,6 @@
" print(\"\\nFinal response:\", v[\"response\"])\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "628ce907",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
9 changes: 5 additions & 4 deletions agent-architectures/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
langchain-openai==0.3.35
langgraph==0.6.10
langchain==0.3.27
langgraph-supervisor==0.0.29
langchain-openai==1.0.1
langgraph==1.0.1
langchain==1.0.2
langchain-core==1.0.1
langgraph-supervisor==0.0.30
langgraph-swarm==0.0.14
langchain-tavily==0.2.12