|
217 | 217 | "search_pipeline.add_component(\"fetcher\", LinkContentFetcher(timeout=3, raise_on_failure=False, retry_attempts=2))\n", |
218 | 218 | "search_pipeline.add_component(\"converter\", HTMLToDocument())\n", |
219 | 219 | "search_pipeline.add_component(\n", |
220 | | - " \"builder\",\n", |
221 | | - " ChatPromptBuilder(\n", |
222 | | - " template=[\n", |
223 | | - " ChatMessage.from_user(\n", |
224 | | - " \"\"\"\n", |
225 | | - "{% for doc in docs %}\n", |
226 | | - " {% if doc.content %}\n", |
| 220 | + " \"output_adapter\",\n", |
| 221 | + " OutputAdapter(\n", |
| 222 | + " template=\"\"\"\n", |
| 223 | + "{%- for doc in docs -%}\n", |
| 224 | + " {%- if doc.content -%}\n", |
227 | 225 | " <search-result url=\"{{ doc.meta.url }}\">\n", |
228 | 226 | " {{ doc.content|truncate(25000) }}\n", |
229 | 227 | " </search-result>\n", |
230 | | - " {% endif %}\n", |
231 | | - "{% endfor %}\n", |
| 228 | + " {%- endif -%}\n", |
| 229 | + "{%- endfor -%}\n", |
232 | 230 | "\"\"\"\n", |
233 | | - " )\n", |
234 | | - " ],\n", |
235 | | - " variables=[\"docs\"],\n", |
236 | | - " required_variables=[\"docs\"],\n", |
| 231 | + " output_type=str,\n", |
237 | 232 | " ),\n", |
238 | 233 | ")\n", |
239 | 234 | "\n", |
240 | 235 | "search_pipeline.connect(\"search.links\", \"fetcher.urls\")\n", |
241 | 236 | "search_pipeline.connect(\"fetcher.streams\", \"converter.sources\")\n", |
242 | | - "search_pipeline.connect(\"converter.documents\", \"builder.docs\")" |
| 237 | + "search_pipeline.connect(\"converter.documents\", \"output_adapter.docs\")" |
243 | 238 | ] |
244 | 239 | }, |
245 | 240 | { |
|
268 | 263 | "from haystack.components.agents import Agent\n", |
269 | 264 | "from haystack.components.generators.chat import OpenAIChatGenerator\n", |
270 | 265 | "\n", |
271 | | - "search_component = SuperComponent(pipeline=search_pipeline)\n", |
| 266 | + "search_component = SuperComponent(\n", |
| 267 | + " pipeline=search_pipeline,\n", |
| 268 | + " input_mapping={\"query\": [\"search.query\"]},\n", |
| 269 | + " output_mapping={\"output_adapter.output\": \"search_result\"}\n", |
| 270 | + ")\n", |
272 | 271 | "search_tool = ComponentTool(\n", |
273 | 272 | " name=\"search\", description=\"Use this tool to search for information on the internet.\", component=search_component\n", |
274 | 273 | ")\n", |
|
0 commit comments