|
188 | 188 | "source": [ |
189 | 189 | "## Using Agent with a Pipeline as Tool\n", |
190 | 190 | "\n", |
191 | | - "Now, for a more sophisticated example, let's build a research assistant that can search the web, fetch content from links, and generate comprehensive answers. In contrast to our previous Agent, we now want to follow the links on the search engine results page and access their content. We'll start with a Haystack Pipeline that the Agent can use as a tool:" |
| 191 | + "Now, for a more sophisticated example, let's build a research assistant that can search the web, fetch content from links, and generate comprehensive answers. In contrast to our previous Agent, we now want to follow the links on the search engine results page, access their content and parse their content through [OutputAdapter](https://docs.haystack.deepset.ai/docs/outputadapter). We'll start with a Haystack Pipeline that the Agent can use as a tool:" |
192 | 192 | ] |
193 | 193 | }, |
194 | 194 | { |
|
245 | 245 | "source": [ |
246 | 246 | "### Creating a Tool from a Pipeline\n", |
247 | 247 | "\n", |
248 | | - "As the next step, create a `SuperComponent` with the `search_pipeline` and convert it into a tool with `ComponentTool`. Then, you can initialize the Agent with the created `search_tool`\n", |
| 248 | + "Next, wrap the `search_pipeline` inside a [`SuperComponent`](https://docs.haystack.deepset.ai/docs/supercomponents) and turn it into a tool using `ComponentTool`. The `ComponentTool` automatically creates LLM-compatible tool schemas based on the component’s input sockets. \n", |
| 249 | + "\n", |
| 250 | + "To control what data the `ComponentTool` should receive and returns, you can optionally define `input_mapping` and `output_mapping`. For example, this lets you ensure that only the `\"query\"` input of the `search_pipeline` is mentioned in LLM-compatible tool schema, and only `\"search_result\"` is returned from the `SuperComponent`.\n", |
| 251 | + "\n", |
| 252 | + "Finally, you can initialize the Agent with the resulting `search_tool`.\n", |
249 | 253 | "\n", |
250 | 254 | "> 💡 Learn alternative ways of creating tools in [`Tool`](https://docs.haystack.deepset.ai/docs/tool) and [`MCPTool`](https://docs.haystack.deepset.ai/docs/mcptool) documentation pages." |
251 | 255 | ] |
|
266 | 270 | "search_component = SuperComponent(\n", |
267 | 271 | " pipeline=search_pipeline,\n", |
268 | 272 | " input_mapping={\"query\": [\"search.query\"]},\n", |
269 | | - " output_mapping={\"output_adapter.output\": \"search_result\"}\n", |
| 273 | + " output_mapping={\"output_adapter.output\": \"search_result\"},\n", |
270 | 274 | ")\n", |
| 275 | + "\n", |
271 | 276 | "search_tool = ComponentTool(\n", |
272 | 277 | " name=\"search\",\n", |
273 | 278 | " description=\"Use this tool to search for information on the internet.\",\n", |
274 | 279 | " component=search_component,\n", |
275 | | - " outputs_to_string={\"source\": \"search_result\"}\n", |
| 280 | + " outputs_to_string={\"source\": \"search_result\"},\n", |
276 | 281 | ")\n", |
277 | 282 | "\n", |
278 | 283 | "agent = Agent(\n", |
|
0 commit comments