Skip to content

Commit ec9b810

Browse files
authored
docs: add YAML example for agent pipeline configuration in documentation (#11110)
1 parent 072935b commit ec9b810

2 files changed

Lines changed: 222 additions & 0 deletions

File tree

  • docs-website
    • docs/pipeline-components/agents-1
    • versioned_docs/version-2.27/pipeline-components/agents-1

docs-website/docs/pipeline-components/agents-1/agent.mdx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,117 @@ agent_output = extraction_agent.run(
244244
print(agent_output["database_agent"]["messages"][-1].text)
245245
```
246246

247+
### In YAML
248+
The example pipeline below fetches a webpage, converts its HTML to text, and builds a chat prompt combining the page content with a user query.
249+
The `Agent` then answers the question based on the provided content and can use its web search tool to find additional information if needed.
250+
251+
```yaml
252+
components:
253+
agent:
254+
init_parameters:
255+
chat_generator:
256+
init_parameters:
257+
api_base_url: null
258+
api_key:
259+
env_vars:
260+
- OPENAI_API_KEY
261+
strict: true
262+
type: env_var
263+
generation_kwargs: {}
264+
http_client_kwargs: null
265+
max_retries: null
266+
model: gpt-4o-mini
267+
organization: null
268+
streaming_callback: null
269+
timeout: null
270+
tools: null
271+
tools_strict: false
272+
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
273+
confirmation_strategies: null
274+
exit_conditions:
275+
- text
276+
max_agent_steps: 5
277+
raise_on_tool_invocation_failure: false
278+
required_variables: null
279+
state_schema: {}
280+
streaming_callback: null
281+
system_prompt: You are a helpful assistant. Use the web search tool to find
282+
information when needed.
283+
tool_invoker_kwargs: null
284+
tools:
285+
- data:
286+
component:
287+
init_parameters:
288+
allowed_domains: null
289+
api_key:
290+
env_vars:
291+
- SERPERDEV_API_KEY
292+
strict: true
293+
type: env_var
294+
exclude_subdomains: false
295+
search_params: {}
296+
top_k: 3
297+
type: haystack.components.websearch.serper_dev.SerperDevWebSearch
298+
description: Search the web for current information on any topic
299+
inputs_from_state: null
300+
name: web_search
301+
outputs_to_state: null
302+
outputs_to_string: null
303+
parameters: null
304+
type: haystack.tools.component_tool.ComponentTool
305+
user_prompt: null
306+
type: haystack.components.agents.agent.Agent
307+
converter:
308+
init_parameters:
309+
extraction_kwargs: {}
310+
store_full_path: false
311+
type: haystack.components.converters.html.HTMLToDocument
312+
fetcher:
313+
init_parameters:
314+
client_kwargs:
315+
follow_redirects: true
316+
timeout: 3
317+
http2: false
318+
raise_on_failure: true
319+
request_headers: {}
320+
retry_attempts: 2
321+
timeout: 3
322+
user_agents:
323+
- haystack/LinkContentFetcher/2.27.0rc0
324+
type: haystack.components.fetchers.link_content.LinkContentFetcher
325+
prompt_builder:
326+
init_parameters:
327+
required_variables:
328+
- docs
329+
- query
330+
template:
331+
- content:
332+
- text: 'Based on the following content:
333+
334+
{% for doc in docs %}
335+
336+
{{ doc.content }}
337+
338+
{% endfor %}
339+
340+
Answer this question: {{ query }}'
341+
meta: {}
342+
name: null
343+
role: user
344+
variables: null
345+
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
346+
connection_type_validation: true
347+
connections:
348+
- receiver: converter.sources
349+
sender: fetcher.streams
350+
- receiver: prompt_builder.docs
351+
sender: converter.documents
352+
- receiver: agent.messages
353+
sender: prompt_builder.prompt
354+
max_runs_per_component: 100
355+
metadata: {}
356+
```
357+
247358
## Additional References
248359
249360
🧑‍🍳 Cookbook: [Build a GitHub Issue Resolver Agent](https://haystack.deepset.ai/cookbook/github_issue_resolver_agent)

docs-website/versioned_docs/version-2.27/pipeline-components/agents-1/agent.mdx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,117 @@ agent_output = extraction_agent.run(
244244
print(agent_output["database_agent"]["messages"][-1].text)
245245
```
246246

247+
### In YAML
248+
The example pipeline below fetches a webpage, converts its HTML to text, and builds a chat prompt combining the page content with a user query.
249+
The `Agent` then answers the question based on the provided content and can use its web search tool to find additional information if needed.
250+
251+
```yaml
252+
components:
253+
agent:
254+
init_parameters:
255+
chat_generator:
256+
init_parameters:
257+
api_base_url: null
258+
api_key:
259+
env_vars:
260+
- OPENAI_API_KEY
261+
strict: true
262+
type: env_var
263+
generation_kwargs: {}
264+
http_client_kwargs: null
265+
max_retries: null
266+
model: gpt-4o-mini
267+
organization: null
268+
streaming_callback: null
269+
timeout: null
270+
tools: null
271+
tools_strict: false
272+
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
273+
confirmation_strategies: null
274+
exit_conditions:
275+
- text
276+
max_agent_steps: 5
277+
raise_on_tool_invocation_failure: false
278+
required_variables: null
279+
state_schema: {}
280+
streaming_callback: null
281+
system_prompt: You are a helpful assistant. Use the web search tool to find
282+
information when needed.
283+
tool_invoker_kwargs: null
284+
tools:
285+
- data:
286+
component:
287+
init_parameters:
288+
allowed_domains: null
289+
api_key:
290+
env_vars:
291+
- SERPERDEV_API_KEY
292+
strict: true
293+
type: env_var
294+
exclude_subdomains: false
295+
search_params: {}
296+
top_k: 3
297+
type: haystack.components.websearch.serper_dev.SerperDevWebSearch
298+
description: Search the web for current information on any topic
299+
inputs_from_state: null
300+
name: web_search
301+
outputs_to_state: null
302+
outputs_to_string: null
303+
parameters: null
304+
type: haystack.tools.component_tool.ComponentTool
305+
user_prompt: null
306+
type: haystack.components.agents.agent.Agent
307+
converter:
308+
init_parameters:
309+
extraction_kwargs: {}
310+
store_full_path: false
311+
type: haystack.components.converters.html.HTMLToDocument
312+
fetcher:
313+
init_parameters:
314+
client_kwargs:
315+
follow_redirects: true
316+
timeout: 3
317+
http2: false
318+
raise_on_failure: true
319+
request_headers: {}
320+
retry_attempts: 2
321+
timeout: 3
322+
user_agents:
323+
- haystack/LinkContentFetcher/2.27.0rc0
324+
type: haystack.components.fetchers.link_content.LinkContentFetcher
325+
prompt_builder:
326+
init_parameters:
327+
required_variables:
328+
- docs
329+
- query
330+
template:
331+
- content:
332+
- text: 'Based on the following content:
333+
334+
{% for doc in docs %}
335+
336+
{{ doc.content }}
337+
338+
{% endfor %}
339+
340+
Answer this question: {{ query }}'
341+
meta: {}
342+
name: null
343+
role: user
344+
variables: null
345+
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
346+
connection_type_validation: true
347+
connections:
348+
- receiver: converter.sources
349+
sender: fetcher.streams
350+
- receiver: prompt_builder.docs
351+
sender: converter.documents
352+
- receiver: agent.messages
353+
sender: prompt_builder.prompt
354+
max_runs_per_component: 100
355+
metadata: {}
356+
```
357+
247358
## Additional References
248359
249360
🧑‍🍳 Cookbook: [Build a GitHub Issue Resolver Agent](https://haystack.deepset.ai/cookbook/github_issue_resolver_agent)

0 commit comments

Comments
 (0)