Skip to content
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

Using anchors and aliases in Pipeline YAML #8689

Open
julian-risch opened this issue Jan 9, 2025 · 0 comments
Open

Using anchors and aliases in Pipeline YAML #8689

julian-risch opened this issue Jan 9, 2025 · 0 comments
Labels
P3 Low priority, leave it in the backlog

Comments

@julian-risch
Copy link
Member

Is your feature request related to a problem? Please describe.
ChatGenerators and ToolInvokers both have a tools parameter and in many pipelines, the tools parameter can be set to the same object: the same tool/list of tools.

Describe the solution you'd like
We should investigate if and how anchors and aliases can be used in Haystack pipelines.

Example without anchors and aliases
Simple pipeline with tools based on cookbook.

Pipeline 1 ```yaml components: generator: init_parameters: api_base_url: null api_key: env_vars: - OPENAI_API_KEY strict: true type: env_var generation_kwargs: {} max_retries: null model: gpt-4o-mini organization: null streaming_callback: null timeout: null tools: - description: A tool to get the weather function: __main__.dummy_weather name: weather parameters: properties: location: type: string required: - location type: object tools_strict: false type: haystack.components.generators.chat.openai.OpenAIChatGenerator router: init_parameters: custom_filters: {} optional_variables: [] routes: - condition: '{{replies[0].tool_calls | length > 0}}' output: '{{replies}}' output_name: there_are_tool_calls output_type: typing.List[haystack.dataclasses.chat_message.ChatMessage] - condition: '{{replies[0].tool_calls | length == 0}}' output: '{{replies}}' output_name: final_replies output_type: typing.List[haystack.dataclasses.chat_message.ChatMessage] unsafe: true validate_output_type: false type: haystack.components.routers.conditional_router.ConditionalRouter tool_invoker: init_parameters: convert_result_to_json_string: false raise_on_failure: true tools: - description: A tool to get the weather function: __main__.dummy_weather name: weather parameters: properties: location: type: string required: - location type: object type: haystack.components.tools.tool_invoker.ToolInvoker connections: - receiver: router.replies sender: generator.replies - receiver: tool_invoker.messages sender: router.there_are_tool_calls max_runs_per_component: 100 metadata: {} ```

Example with anchors and aliases
Note how *id001 is used for the tools parameter of ToolInvoker instead of redefining what was already used for the tools parameter of the OpenAIChatGenerator under &id001

Pipeline 2 ```yaml components: generator: init_parameters: api_base_url: null api_key: env_vars: - OPENAI_API_KEY strict: true type: env_var generation_kwargs: {} max_retries: null model: gpt-4o-mini organization: null streaming_callback: null timeout: null tools: &id001 - description: A tool to get the weather function: __main__.dummy_weather name: weather parameters: properties: location: type: string required: - location type: object tools_strict: false type: haystack.components.generators.chat.openai.OpenAIChatGenerator router: init_parameters: custom_filters: {} optional_variables: [] routes: - condition: '{{replies[0].tool_calls | length > 0}}' output: '{{replies}}' output_name: there_are_tool_calls output_type: typing.List[haystack.dataclasses.chat_message.ChatMessage] - condition: '{{replies[0].tool_calls | length == 0}}' output: '{{replies}}' output_name: final_replies output_type: typing.List[haystack.dataclasses.chat_message.ChatMessage] unsafe: true validate_output_type: false type: haystack.components.routers.conditional_router.ConditionalRouter tool_invoker: init_parameters: convert_result_to_json_string: false raise_on_failure: true tools: *id001 type: haystack.components.tools.tool_invoker.ToolInvoker connections: - receiver: router.replies sender: generator.replies - receiver: tool_invoker.messages sender: router.there_are_tool_calls max_runs_per_component: 100 metadata: {} ```
@julian-risch julian-risch added the P3 Low priority, leave it in the backlog label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Low priority, leave it in the backlog
Projects
None yet
Development

No branches or pull requests

1 participant