Skip to content

Update 43_Building_a_Tool_Calling_Agent.ipynb #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2025
Merged
Changes from 1 commit
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
29 changes: 14 additions & 15 deletions tutorials/43_Building_a_Tool_Calling_Agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,24 @@
"search_pipeline.add_component(\"fetcher\", LinkContentFetcher(timeout=3, raise_on_failure=False, retry_attempts=2))\n",
"search_pipeline.add_component(\"converter\", HTMLToDocument())\n",
"search_pipeline.add_component(\n",
" \"builder\",\n",
" ChatPromptBuilder(\n",
" template=[\n",
" ChatMessage.from_user(\n",
" \"\"\"\n",
"{% for doc in docs %}\n",
" {% if doc.content %}\n",
" \"output_adapter\",\n",
" OutputAdapter(\n",
" template=\"\"\"\n",
"{%- for doc in docs -%}\n",
" {%- if doc.content -%}\n",
" <search-result url=\"{{ doc.meta.url }}\">\n",
" {{ doc.content|truncate(25000) }}\n",
" </search-result>\n",
" {% endif %}\n",
"{% endfor %}\n",
" {%- endif -%}\n",
"{%- endfor -%}\n",
"\"\"\"\n",
" )\n",
" ],\n",
" variables=[\"docs\"],\n",
" required_variables=[\"docs\"],\n",
" output_type=str,\n",
" ),\n",
")\n",
"\n",
"search_pipeline.connect(\"search.links\", \"fetcher.urls\")\n",
"search_pipeline.connect(\"fetcher.streams\", \"converter.sources\")\n",
"search_pipeline.connect(\"converter.documents\", \"builder.docs\")"
"search_pipeline.connect(\"converter.documents\", \"output_adapter.docs\")"
]
},
{
Expand Down Expand Up @@ -268,7 +263,11 @@
"from haystack.components.agents import Agent\n",
"from haystack.components.generators.chat import OpenAIChatGenerator\n",
"\n",
"search_component = SuperComponent(pipeline=search_pipeline)\n",
"search_component = SuperComponent(\n",
" pipeline=search_pipeline,\n",
" input_mapping={\"query\": [\"search.query\"]},\n",
" output_mapping={\"output_adapter.output\": \"search_result\"}\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bilgeyucel I added these here to show how to use these in a SuperComponent context as well as to make the parameter specification of the ComponentTool only contain query instead of all possible inputs the SuperComponent could take.

")\n",
"search_tool = ComponentTool(\n",
" name=\"search\", description=\"Use this tool to search for information on the internet.\", component=search_component\n",
")\n",
Expand Down
Loading