You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Check if a pipeline yaml with manually added anchors and aliases can be loaded correctly
Investigate when the YamlDumper makes use of anchors and aliases
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
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 thetools
parameter ofToolInvoker
instead of redefining what was already used for thetools
parameter of theOpenAIChatGenerator
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: {} ```The text was updated successfully, but these errors were encountered: