33# SPDX-License-Identifier: Apache-2.0
44
55from dataclasses import replace
6- from typing import Any , Optional , Union
6+ from typing import Any , Optional
77
88from haystack import component
99from haystack .components .generators .chat .openai import OpenAIChatGenerator as BaseOpenAIChatGenerator
1010from haystack .dataclasses import ChatMessage , StreamingCallbackT
11- from haystack .tools import Tool , Toolset
11+ from haystack .tools import ToolsType
1212
1313from haystack_experimental .utils .hallucination_risk_calculator .dataclasses import HallucinationScoreConfig
1414from haystack_experimental .utils .hallucination_risk_calculator .openai_planner import calculate_hallucination_metrics
@@ -59,7 +59,7 @@ def run(
5959 streaming_callback : Optional [StreamingCallbackT ] = None ,
6060 generation_kwargs : Optional [dict [str , Any ]] = None ,
6161 * ,
62- tools : Optional [Union [ list [ Tool ], Toolset ] ] = None ,
62+ tools : Optional [ToolsType ] = None ,
6363 tools_strict : Optional [bool ] = None ,
6464 hallucination_score_config : Optional [HallucinationScoreConfig ] = None ,
6565 ) -> dict [str , list [ChatMessage ]]:
@@ -75,9 +75,8 @@ def run(
7575 override the parameters passed during component initialization.
7676 For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
7777 :param tools:
78- A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
79- `tools` parameter set during component initialization. This parameter can accept either a list of
80- `Tool` objects or a `Toolset` instance.
78+ A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
79+ If set, it will override the `tools` parameter provided during initialization.
8180 :param tools_strict:
8281 Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
8382 the schema provided in the `parameters` field of the tool definition, but this may increase latency.
@@ -127,7 +126,7 @@ async def run_async(
127126 streaming_callback : Optional [StreamingCallbackT ] = None ,
128127 generation_kwargs : Optional [dict [str , Any ]] = None ,
129128 * ,
130- tools : Optional [Union [ list [ Tool ], Toolset ] ] = None ,
129+ tools : Optional [ToolsType ] = None ,
131130 tools_strict : Optional [bool ] = None ,
132131 hallucination_score_config : Optional [HallucinationScoreConfig ] = None ,
133132 ) -> dict [str , list [ChatMessage ]]:
@@ -147,9 +146,8 @@ async def run_async(
147146 override the parameters passed during component initialization.
148147 For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
149148 :param tools:
150- A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
151- `tools` parameter set during component initialization. This parameter can accept either a list of
152- `Tool` objects or a `Toolset` instance.
149+ A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
150+ If set, it will override the `tools` parameter provided during initialization.
153151 :param tools_strict:
154152 Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
155153 the schema provided in the `parameters` field of the tool definition, but this may increase latency.
0 commit comments