Skip to content

Commit dd4bef2

Browse files
authored
docs: Fix Issues with Hierarchical tutorial (#1353)
1 parent 22aaa29 commit dd4bef2

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

examples/multi_agent/hierarchical_agent_teams.ipynb

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@
5656
"// import \"dotenv/config\";\n"
5757
]
5858
},
59+
{
60+
"cell_type": "markdown",
61+
"id": "b2fe13d8",
62+
"metadata": {},
63+
"source": [
64+
"### Install dependencies\n",
65+
"\n",
66+
"```bash\n",
67+
"npm install @langchain/community @langchain/core @langchain/langgraph @langchain/openai @langchain/tavily canvas cheerio d3 tslab zod\n",
68+
"```"
69+
]
70+
},
5971
{
6072
"cell_type": "markdown",
6173
"id": "11f28f8d",
@@ -77,17 +89,17 @@
7789
},
7890
{
7991
"cell_type": "code",
80-
"execution_count": 2,
92+
"execution_count": null,
8193
"id": "193df01b",
8294
"metadata": {},
8395
"outputs": [],
8496
"source": [
85-
"import { TavilySearchResults } from \"@langchain/community/tools/tavily_search\";\n",
97+
"import { TavilySearch } from \"@langchain/tavily\";\n",
8698
"import { CheerioWebBaseLoader } from \"@langchain/community/document_loaders/web/cheerio\";\n",
8799
"import { tool } from \"@langchain/core/tools\";\n",
88100
"import { z } from \"zod\";\n",
89101
"\n",
90-
"const tavilyTool = new TavilySearchResults();\n",
102+
"const tavilyTool = new TavilySearch();\n",
91103
"\n",
92104
"const scrapeWebpage = tool(async (input) => {\n",
93105
" const loader = new CheerioWebBaseLoader(input.url);\n",
@@ -440,7 +452,7 @@
440452
" ChatPromptTemplate,\n",
441453
" MessagesPlaceholder,\n",
442454
"} from \"@langchain/core/prompts\";\n",
443-
"import { JsonOutputToolsParser } from \"langchain/output_parsers\";\n",
455+
"import { JsonOutputToolsParser } from \"@langchain/core/output_parsers/openai_tools\"\n",
444456
"import { ChatOpenAI } from \"@langchain/openai\";\n",
445457
"import { Runnable } from \"@langchain/core/runnables\";\n",
446458
"import { StructuredToolInterface } from \"@langchain/core/tools\";\n",
@@ -624,7 +636,7 @@
624636
},
625637
{
626638
"cell_type": "code",
627-
"execution_count": 9,
639+
"execution_count": null,
628640
"id": "dff6a285",
629641
"metadata": {},
630642
"outputs": [],
@@ -645,7 +657,16 @@
645657
" })\n",
646658
" .addEdge(START, \"supervisor\");\n",
647659
"\n",
648-
"const researchChain = researchGraph.compile();"
660+
"const enterResearchChain = RunnableLambda.from(\n",
661+
" ({ messages }: { messages: BaseMessage[] }) => {\n",
662+
" return {\n",
663+
" messages: messages,\n",
664+
" team_members: [\"Search\", \"WebScraper\"],\n",
665+
" };\n",
666+
" },\n",
667+
");\n",
668+
"\n",
669+
"const researchChain = enterResearchChain.pipe(() => researchGraph.compile());"
649670
]
650671
},
651672
{
@@ -953,7 +974,7 @@
953974
},
954975
{
955976
"cell_type": "code",
956-
"execution_count": 14,
977+
"execution_count": null,
957978
"id": "2ab60a98",
958979
"metadata": {},
959980
"outputs": [],
@@ -985,7 +1006,7 @@
9851006
" };\n",
9861007
" },\n",
9871008
");\n",
988-
"const authoringChain = enterAuthoringChain.pipe(authoringGraph.compile());"
1009+
"const authoringChain = enterAuthoringChain.pipe(() => authoringGraph.compile());"
9891010
]
9901011
},
9911012
{
@@ -1243,7 +1264,7 @@
12431264
},
12441265
{
12451266
"cell_type": "code",
1246-
"execution_count": 66,
1267+
"execution_count": null,
12471268
"id": "0f40c195",
12481269
"metadata": {},
12491270
"outputs": [],
@@ -1257,6 +1278,7 @@
12571278
" const joinGraphResult = await joinGraph.invoke({\n",
12581279
" messages: researchChainResult.messages,\n",
12591280
" });\n",
1281+
" return joinGraphResult;\n",
12601282
" })\n",
12611283
" .addNode(\"PaperWritingTeam\", getMessages.pipe(authoringChain).pipe(joinGraph))\n",
12621284
" .addNode(\"supervisor\", supervisorNode)\n",

0 commit comments

Comments
 (0)