diff --git a/docs-website/reference/integrations-api/amazon_bedrock.md b/docs-website/reference/integrations-api/amazon_bedrock.md index 5bb9645dc5..a9383e8173 100644 --- a/docs-website/reference/integrations-api/amazon_bedrock.md +++ b/docs-website/reference/integrations-api/amazon_bedrock.md @@ -1135,7 +1135,7 @@ def __init__( generation_kwargs: Optional[Dict[str, Any]] = None, streaming_callback: Optional[StreamingCallbackT] = None, boto3_config: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, guardrail_config: Optional[Dict[str, str]] = None) -> None ``` @@ -1168,7 +1168,8 @@ function that handles the streaming chunks. The callback function receives a [StreamingChunk](https://docs.haystack.deepset.ai/docs/data-classes#streamingchunk) object and switches the streaming mode on. - `boto3_config`: The configuration for the boto3 client. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `guardrail_config`: Optional configuration for a guardrail that has been created in Amazon Bedrock. This must be provided as a dictionary matching either [GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html). @@ -1227,12 +1228,10 @@ Instance of `AmazonBedrockChatGenerator`. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes a synchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1248,7 +1247,8 @@ Supports both standard and streaming responses depending on whether a streaming - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tools that the model may call during execution. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: @@ -1265,11 +1265,10 @@ A dictionary containing the model-generated replies under the `"replies"` key. ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes an asynchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1285,7 +1284,8 @@ Designed for use cases where non-blocking or concurrent execution is desired. - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tool objects or a Toolset that the model can use. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: diff --git a/docs-website/reference/integrations-api/anthropic.md b/docs-website/reference/integrations-api/anthropic.md index 4fadc67306..0ea96cf58f 100644 --- a/docs-website/reference/integrations-api/anthropic.md +++ b/docs-website/reference/integrations-api/anthropic.md @@ -196,7 +196,7 @@ def __init__(api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), streaming_callback: Optional[StreamingCallbackT] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -231,7 +231,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. @@ -275,12 +276,10 @@ The deserialized component instance. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Invokes the Anthropic API with the given messages and generation kwargs. @@ -290,8 +289,9 @@ Invokes the Anthropic API with the given messages and generation kwargs. - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -305,11 +305,10 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Async version of the run method. Invokes the Anthropic API with the given messages and generation kwargs. @@ -319,8 +318,9 @@ Async version of the run method. Invokes the Anthropic API with the given messag - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -392,7 +392,7 @@ def __init__(region: str, None]] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[List[Tool]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -425,7 +425,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. diff --git a/docs-website/reference/integrations-api/cohere.md b/docs-website/reference/integrations-api/cohere.md index 8e1c14fb52..5062839bef 100644 --- a/docs-website/reference/integrations-api/cohere.md +++ b/docs-website/reference/integrations-api/cohere.md @@ -745,7 +745,7 @@ def __init__(api_key: Secret = Secret.from_env_var( streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = None, generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, **kwargs: Any) ``` @@ -770,7 +770,8 @@ Some of the parameters are: `accurate` results or `fast` results. - 'temperature': A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset that the model can use. +Each tool should have a unique name. @@ -814,7 +815,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -828,8 +829,8 @@ Invoke the chat endpoint based on the provided messages and generation parameter potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. @@ -847,7 +848,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -861,8 +862,8 @@ Asynchronously invoke the chat endpoint based on the provided messages and gener potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. **Returns**: diff --git a/docs-website/reference/integrations-api/google_genai.md b/docs-website/reference/integrations-api/google_genai.md index bd51dae768..e9cc647592 100644 --- a/docs-website/reference/integrations-api/google_genai.md +++ b/docs-website/reference/integrations-api/google_genai.md @@ -131,7 +131,7 @@ def __init__(*, generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) + tools: Optional[ToolsType] = None) ``` Initialize a GoogleGenAIChatGenerator instance. @@ -156,7 +156,8 @@ For Gemini 2.5 series, supports `thinking_budget` to configure thinking behavior - Positive integer: Set explicit budget - `safety_settings`: Safety settings for content filtering - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. @@ -201,7 +202,7 @@ def run(messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Run the Google Gen AI chat generator on the given input data. @@ -215,8 +216,8 @@ the default config. Supports `thinking_budget` for Gemini 2.5 series thinking co default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: @@ -235,12 +236,11 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) -async def run_async( - messages: List[ChatMessage], - generation_kwargs: Optional[Dict[str, Any]] = None, - safety_settings: Optional[List[Dict[str, Any]]] = None, - streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] +async def run_async(messages: List[ChatMessage], + generation_kwargs: Optional[Dict[str, Any]] = None, + safety_settings: Optional[List[Dict[str, Any]]] = None, + streaming_callback: Optional[StreamingCallbackT] = None, + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Async version of the run method. Run the Google Gen AI chat generator on the given input data. @@ -255,8 +255,8 @@ See https://ai.google.dev/gemini-api/docs/thinking for possible values. default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: diff --git a/docs-website/reference/integrations-api/mcp.md b/docs-website/reference/integrations-api/mcp.md index fb75acbede..73471fc22c 100644 --- a/docs-website/reference/integrations-api/mcp.md +++ b/docs-website/reference/integrations-api/mcp.md @@ -673,7 +673,8 @@ def __init__(name: str, server_info: MCPServerInfo, description: str | None = None, connection_timeout: int = 30, - invocation_timeout: int = 30) + invocation_timeout: int = 30, + eager_connect: bool = False) ``` Initialize the MCP tool. @@ -685,6 +686,9 @@ Initialize the MCP tool. - `description`: Custom description (if None, server description will be used) - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server during initialization. +If False (default), defer connection until warm_up or first tool use, +whichever comes first. **Raises**: @@ -715,6 +719,16 @@ Asynchronous tool invocation. JSON string representation of the tool invocation result + + +#### MCPTool.warm\_up + +```python +def warm_up() -> None +``` + +Connect and fetch the tool schema if eager_connect is turned off. + #### MCPTool.to\_dict @@ -792,20 +806,6 @@ def tool_spec() -> dict[str, Any] Return the Tool specification to be used by the Language Model. - - -#### MCPTool.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Tool for use. - -Override this method to establish connections to remote services, load models, -or perform other resource-intensive initialization. This method should be idempotent, -as it may be called multiple times. - #### MCPTool.invoke @@ -953,7 +953,8 @@ sse_toolset = MCPToolset( def __init__(server_info: MCPServerInfo, tool_names: list[str] | None = None, connection_timeout: float = 30.0, - invocation_timeout: float = 30.0) + invocation_timeout: float = 30.0, + eager_connect: bool = False) ``` Initialize the MCP toolset. @@ -965,11 +966,27 @@ Initialize the MCP toolset. matching names will be added to the toolset. - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server and load tools during initialization. +If False (default), defer connection to warm_up. **Raises**: - `MCPToolNotFoundError`: If any of the specified tool names are not found on the server + + +#### MCPToolset.warm\_up + +```python +def warm_up() -> None +``` + +Connect and load tools when eager_connect is turned off. + +This method is automatically called by ``ToolInvoker.warm_up()`` and ``Pipeline.warm_up()``. +You can also call it directly before using the toolset to ensure all tool schemas +are available without performing a real invocation. + #### MCPToolset.to\_dict @@ -1063,19 +1080,6 @@ Supports checking by: True if contained, False otherwise - - -#### MCPToolset.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Toolset for use. - -Override this method to set up shared resources like database connections or HTTP sessions. -This method should be idempotent, as it may be called multiple times. - #### MCPToolset.add diff --git a/docs-website/reference/integrations-api/mistral.md b/docs-website/reference/integrations-api/mistral.md index 432d8380f7..758ca5d2a8 100644 --- a/docs-website/reference/integrations-api/mistral.md +++ b/docs-website/reference/integrations-api/mistral.md @@ -382,8 +382,8 @@ Some of the supported parameters: Notes: - For structured outputs with streaming, the `response_format` must be a JSON schema and not a Pydantic model. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Mistral API call. If not set, it defaults to either the `OPENAI_TIMEOUT` environment variable, or 30 seconds. - `max_retries`: Maximum number of retries to contact OpenAI after an internal error. diff --git a/docs-website/reference/integrations-api/ollama.md b/docs-website/reference/integrations-api/ollama.md index 1ba5c76aca..eefffbd938 100644 --- a/docs-website/reference/integrations-api/ollama.md +++ b/docs-website/reference/integrations-api/ollama.md @@ -165,7 +165,7 @@ def __init__(model: str = "qwen3:0.6b", keep_alive: Optional[Union[float, str]] = None, streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, response_format: Optional[Union[None, Literal["json"], JsonSchemaValue]] = None, think: Union[bool, Literal["low", "medium", "high"]] = False) @@ -200,9 +200,9 @@ The name of the model to use. The model must already be present (pulled) in the A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. :param tools: - A list of `haystack.tools.Tool` or a `haystack.tools.Toolset`. Duplicate tool names raise a `ValueError`. - Not all models support tools. For a list of models compatible with tools, see the - [models page](https://ollama.com/search?c=tools). + A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. + Each tool should have a unique name. Not all models support tools. For a list of models compatible + with tools, see the [models page](https://ollama.com/search?c=tools). :param response_format: The format for structured model outputs. The value can be: - None: No specific structure or format is applied to the response. The response is returned as-is. @@ -253,7 +253,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -268,9 +268,8 @@ Runs an Ollama Model on a given chat history. These are merged on top of the instance-level `generation_kwargs`. Optional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the [Ollama docs](https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. If set, it will override the `tools` parameter set -during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback (here or in the constructor) switches the component into streaming mode. @@ -289,7 +288,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -302,7 +301,7 @@ Async version of run. Runs an Ollama Model on a given chat history. - `messages`: A list of ChatMessage instances representing the input messages. - `generation_kwargs`: Per-call overrides for Ollama inference options. These are merged on top of the instance-level `generation_kwargs`. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback switches the component into streaming mode. diff --git a/docs-website/reference/integrations-api/snowflake.md b/docs-website/reference/integrations-api/snowflake.md index 064d8a9e5c..45e4f73551 100644 --- a/docs-website/reference/integrations-api/snowflake.md +++ b/docs-website/reference/integrations-api/snowflake.md @@ -32,6 +32,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Key-pair Authentication (MFA): @@ -46,6 +47,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### OAuth Authentication (MFA): @@ -61,6 +63,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Running queries: @@ -93,17 +96,23 @@ shape: (3, 3) ```python def __init__(user: str, account: str, - authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", "OAUTH"], - api_key: Optional[Secret] = None, + authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", + "OAUTH"] = "SNOWFLAKE", + api_key: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_API_KEY", strict=False), database: Optional[str] = None, db_schema: Optional[str] = None, warehouse: Optional[str] = None, login_timeout: Optional[int] = 60, return_markdown: bool = True, - private_key_file: Optional[Secret] = None, - private_key_file_pwd: Optional[Secret] = None, - oauth_client_id: Optional[Secret] = None, - oauth_client_secret: Optional[Secret] = None, + private_key_file: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_FILE", strict=False), + private_key_file_pwd: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_PWD", strict=False), + oauth_client_id: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_ID", strict=False), + oauth_client_secret: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_SECRET", strict=False), oauth_token_request_url: Optional[str] = None, oauth_authorization_url: Optional[str] = None) -> None ``` @@ -131,19 +140,15 @@ Required for OAUTH authentication. - `oauth_token_request_url`: OAuth token request URL for Client Credentials flow. - `oauth_authorization_url`: OAuth authorization URL for Authorization Code flow. - + -#### SnowflakeTableRetriever.test\_connection +#### SnowflakeTableRetriever.warm\_up ```python -def test_connection() -> bool +def warm_up() -> None ``` -Tests the connection with the current authentication settings. - -**Returns**: - -True if connection is successful, False otherwise. +Warm up the component by initializing the authenticator handler and testing the database connection. diff --git a/docs-website/reference/integrations-api/together_ai.md b/docs-website/reference/integrations-api/together_ai.md index 8610d1ce98..5282c17ea3 100644 --- a/docs-website/reference/integrations-api/together_ai.md +++ b/docs-website/reference/integrations-api/together_ai.md @@ -231,7 +231,7 @@ def __init__(*, streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = "https://api.together.xyz/v1", generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, timeout: Optional[float] = None, max_retries: Optional[int] = None, http_client_kwargs: Optional[Dict[str, Any]] = None) @@ -263,8 +263,8 @@ Some of the supported parameters: events as they become available, with the stream terminated by a data: [DONE] message. - `safe_prompt`: Whether to inject a safety prompt before all conversations. - `random_seed`: The seed to use for random sampling. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Together AI API call. - `max_retries`: Maximum number of retries to contact Together AI after an internal error. If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5. diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/amazon_bedrock.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/amazon_bedrock.md index 5bb9645dc5..a9383e8173 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/amazon_bedrock.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/amazon_bedrock.md @@ -1135,7 +1135,7 @@ def __init__( generation_kwargs: Optional[Dict[str, Any]] = None, streaming_callback: Optional[StreamingCallbackT] = None, boto3_config: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, guardrail_config: Optional[Dict[str, str]] = None) -> None ``` @@ -1168,7 +1168,8 @@ function that handles the streaming chunks. The callback function receives a [StreamingChunk](https://docs.haystack.deepset.ai/docs/data-classes#streamingchunk) object and switches the streaming mode on. - `boto3_config`: The configuration for the boto3 client. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `guardrail_config`: Optional configuration for a guardrail that has been created in Amazon Bedrock. This must be provided as a dictionary matching either [GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html). @@ -1227,12 +1228,10 @@ Instance of `AmazonBedrockChatGenerator`. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes a synchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1248,7 +1247,8 @@ Supports both standard and streaming responses depending on whether a streaming - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tools that the model may call during execution. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: @@ -1265,11 +1265,10 @@ A dictionary containing the model-generated replies under the `"replies"` key. ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes an asynchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1285,7 +1284,8 @@ Designed for use cases where non-blocking or concurrent execution is desired. - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tool objects or a Toolset that the model can use. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/anthropic.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/anthropic.md index 4fadc67306..0ea96cf58f 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/anthropic.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/anthropic.md @@ -196,7 +196,7 @@ def __init__(api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), streaming_callback: Optional[StreamingCallbackT] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -231,7 +231,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. @@ -275,12 +276,10 @@ The deserialized component instance. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Invokes the Anthropic API with the given messages and generation kwargs. @@ -290,8 +289,9 @@ Invokes the Anthropic API with the given messages and generation kwargs. - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -305,11 +305,10 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Async version of the run method. Invokes the Anthropic API with the given messages and generation kwargs. @@ -319,8 +318,9 @@ Async version of the run method. Invokes the Anthropic API with the given messag - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -392,7 +392,7 @@ def __init__(region: str, None]] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[List[Tool]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -425,7 +425,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/cohere.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/cohere.md index 8e1c14fb52..5062839bef 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/cohere.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/cohere.md @@ -745,7 +745,7 @@ def __init__(api_key: Secret = Secret.from_env_var( streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = None, generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, **kwargs: Any) ``` @@ -770,7 +770,8 @@ Some of the parameters are: `accurate` results or `fast` results. - 'temperature': A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset that the model can use. +Each tool should have a unique name. @@ -814,7 +815,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -828,8 +829,8 @@ Invoke the chat endpoint based on the provided messages and generation parameter potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. @@ -847,7 +848,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -861,8 +862,8 @@ Asynchronously invoke the chat endpoint based on the provided messages and gener potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. **Returns**: diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/google_genai.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/google_genai.md index bd51dae768..e9cc647592 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/google_genai.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/google_genai.md @@ -131,7 +131,7 @@ def __init__(*, generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) + tools: Optional[ToolsType] = None) ``` Initialize a GoogleGenAIChatGenerator instance. @@ -156,7 +156,8 @@ For Gemini 2.5 series, supports `thinking_budget` to configure thinking behavior - Positive integer: Set explicit budget - `safety_settings`: Safety settings for content filtering - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. @@ -201,7 +202,7 @@ def run(messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Run the Google Gen AI chat generator on the given input data. @@ -215,8 +216,8 @@ the default config. Supports `thinking_budget` for Gemini 2.5 series thinking co default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: @@ -235,12 +236,11 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) -async def run_async( - messages: List[ChatMessage], - generation_kwargs: Optional[Dict[str, Any]] = None, - safety_settings: Optional[List[Dict[str, Any]]] = None, - streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] +async def run_async(messages: List[ChatMessage], + generation_kwargs: Optional[Dict[str, Any]] = None, + safety_settings: Optional[List[Dict[str, Any]]] = None, + streaming_callback: Optional[StreamingCallbackT] = None, + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Async version of the run method. Run the Google Gen AI chat generator on the given input data. @@ -255,8 +255,8 @@ See https://ai.google.dev/gemini-api/docs/thinking for possible values. default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/mcp.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/mcp.md index fb75acbede..73471fc22c 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/mcp.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/mcp.md @@ -673,7 +673,8 @@ def __init__(name: str, server_info: MCPServerInfo, description: str | None = None, connection_timeout: int = 30, - invocation_timeout: int = 30) + invocation_timeout: int = 30, + eager_connect: bool = False) ``` Initialize the MCP tool. @@ -685,6 +686,9 @@ Initialize the MCP tool. - `description`: Custom description (if None, server description will be used) - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server during initialization. +If False (default), defer connection until warm_up or first tool use, +whichever comes first. **Raises**: @@ -715,6 +719,16 @@ Asynchronous tool invocation. JSON string representation of the tool invocation result + + +#### MCPTool.warm\_up + +```python +def warm_up() -> None +``` + +Connect and fetch the tool schema if eager_connect is turned off. + #### MCPTool.to\_dict @@ -792,20 +806,6 @@ def tool_spec() -> dict[str, Any] Return the Tool specification to be used by the Language Model. - - -#### MCPTool.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Tool for use. - -Override this method to establish connections to remote services, load models, -or perform other resource-intensive initialization. This method should be idempotent, -as it may be called multiple times. - #### MCPTool.invoke @@ -953,7 +953,8 @@ sse_toolset = MCPToolset( def __init__(server_info: MCPServerInfo, tool_names: list[str] | None = None, connection_timeout: float = 30.0, - invocation_timeout: float = 30.0) + invocation_timeout: float = 30.0, + eager_connect: bool = False) ``` Initialize the MCP toolset. @@ -965,11 +966,27 @@ Initialize the MCP toolset. matching names will be added to the toolset. - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server and load tools during initialization. +If False (default), defer connection to warm_up. **Raises**: - `MCPToolNotFoundError`: If any of the specified tool names are not found on the server + + +#### MCPToolset.warm\_up + +```python +def warm_up() -> None +``` + +Connect and load tools when eager_connect is turned off. + +This method is automatically called by ``ToolInvoker.warm_up()`` and ``Pipeline.warm_up()``. +You can also call it directly before using the toolset to ensure all tool schemas +are available without performing a real invocation. + #### MCPToolset.to\_dict @@ -1063,19 +1080,6 @@ Supports checking by: True if contained, False otherwise - - -#### MCPToolset.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Toolset for use. - -Override this method to set up shared resources like database connections or HTTP sessions. -This method should be idempotent, as it may be called multiple times. - #### MCPToolset.add diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/mistral.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/mistral.md index 432d8380f7..758ca5d2a8 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/mistral.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/mistral.md @@ -382,8 +382,8 @@ Some of the supported parameters: Notes: - For structured outputs with streaming, the `response_format` must be a JSON schema and not a Pydantic model. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Mistral API call. If not set, it defaults to either the `OPENAI_TIMEOUT` environment variable, or 30 seconds. - `max_retries`: Maximum number of retries to contact OpenAI after an internal error. diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/ollama.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/ollama.md index 1ba5c76aca..eefffbd938 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/ollama.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/ollama.md @@ -165,7 +165,7 @@ def __init__(model: str = "qwen3:0.6b", keep_alive: Optional[Union[float, str]] = None, streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, response_format: Optional[Union[None, Literal["json"], JsonSchemaValue]] = None, think: Union[bool, Literal["low", "medium", "high"]] = False) @@ -200,9 +200,9 @@ The name of the model to use. The model must already be present (pulled) in the A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. :param tools: - A list of `haystack.tools.Tool` or a `haystack.tools.Toolset`. Duplicate tool names raise a `ValueError`. - Not all models support tools. For a list of models compatible with tools, see the - [models page](https://ollama.com/search?c=tools). + A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. + Each tool should have a unique name. Not all models support tools. For a list of models compatible + with tools, see the [models page](https://ollama.com/search?c=tools). :param response_format: The format for structured model outputs. The value can be: - None: No specific structure or format is applied to the response. The response is returned as-is. @@ -253,7 +253,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -268,9 +268,8 @@ Runs an Ollama Model on a given chat history. These are merged on top of the instance-level `generation_kwargs`. Optional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the [Ollama docs](https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. If set, it will override the `tools` parameter set -during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback (here or in the constructor) switches the component into streaming mode. @@ -289,7 +288,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -302,7 +301,7 @@ Async version of run. Runs an Ollama Model on a given chat history. - `messages`: A list of ChatMessage instances representing the input messages. - `generation_kwargs`: Per-call overrides for Ollama inference options. These are merged on top of the instance-level `generation_kwargs`. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback switches the component into streaming mode. diff --git a/docs-website/reference_versioned_docs/version-2.17/qdrant.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/qdrant.md similarity index 99% rename from docs-website/reference_versioned_docs/version-2.17/qdrant.md rename to docs-website/reference_versioned_docs/version-2.17/integrations-api/qdrant.md index 2d9436ce42..6846a84d13 100644 --- a/docs-website/reference_versioned_docs/version-2.17/qdrant.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/qdrant.md @@ -1038,4 +1038,3 @@ new_document_store = QdrantDocumentStore(url="http://localhost:6333", - `old_document_store`: The existing QdrantDocumentStore instance to migrate from. - `new_index`: The name of the new index/collection to create with sparse embeddings support. - diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/snowflake.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/snowflake.md index 064d8a9e5c..45e4f73551 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/snowflake.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/snowflake.md @@ -32,6 +32,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Key-pair Authentication (MFA): @@ -46,6 +47,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### OAuth Authentication (MFA): @@ -61,6 +63,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Running queries: @@ -93,17 +96,23 @@ shape: (3, 3) ```python def __init__(user: str, account: str, - authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", "OAUTH"], - api_key: Optional[Secret] = None, + authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", + "OAUTH"] = "SNOWFLAKE", + api_key: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_API_KEY", strict=False), database: Optional[str] = None, db_schema: Optional[str] = None, warehouse: Optional[str] = None, login_timeout: Optional[int] = 60, return_markdown: bool = True, - private_key_file: Optional[Secret] = None, - private_key_file_pwd: Optional[Secret] = None, - oauth_client_id: Optional[Secret] = None, - oauth_client_secret: Optional[Secret] = None, + private_key_file: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_FILE", strict=False), + private_key_file_pwd: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_PWD", strict=False), + oauth_client_id: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_ID", strict=False), + oauth_client_secret: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_SECRET", strict=False), oauth_token_request_url: Optional[str] = None, oauth_authorization_url: Optional[str] = None) -> None ``` @@ -131,19 +140,15 @@ Required for OAUTH authentication. - `oauth_token_request_url`: OAuth token request URL for Client Credentials flow. - `oauth_authorization_url`: OAuth authorization URL for Authorization Code flow. - + -#### SnowflakeTableRetriever.test\_connection +#### SnowflakeTableRetriever.warm\_up ```python -def test_connection() -> bool +def warm_up() -> None ``` -Tests the connection with the current authentication settings. - -**Returns**: - -True if connection is successful, False otherwise. +Warm up the component by initializing the authenticator handler and testing the database connection. diff --git a/docs-website/reference_versioned_docs/version-2.17/integrations-api/together_ai.md b/docs-website/reference_versioned_docs/version-2.17/integrations-api/together_ai.md index 8610d1ce98..5282c17ea3 100644 --- a/docs-website/reference_versioned_docs/version-2.17/integrations-api/together_ai.md +++ b/docs-website/reference_versioned_docs/version-2.17/integrations-api/together_ai.md @@ -231,7 +231,7 @@ def __init__(*, streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = "https://api.together.xyz/v1", generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, timeout: Optional[float] = None, max_retries: Optional[int] = None, http_client_kwargs: Optional[Dict[str, Any]] = None) @@ -263,8 +263,8 @@ Some of the supported parameters: events as they become available, with the stream terminated by a data: [DONE] message. - `safe_prompt`: Whether to inject a safety prompt before all conversations. - `random_seed`: The seed to use for random sampling. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Together AI API call. - `max_retries`: Maximum number of retries to contact Together AI after an internal error. If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5. diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/amazon_bedrock.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/amazon_bedrock.md index 5bb9645dc5..a9383e8173 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/amazon_bedrock.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/amazon_bedrock.md @@ -1135,7 +1135,7 @@ def __init__( generation_kwargs: Optional[Dict[str, Any]] = None, streaming_callback: Optional[StreamingCallbackT] = None, boto3_config: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, guardrail_config: Optional[Dict[str, str]] = None) -> None ``` @@ -1168,7 +1168,8 @@ function that handles the streaming chunks. The callback function receives a [StreamingChunk](https://docs.haystack.deepset.ai/docs/data-classes#streamingchunk) object and switches the streaming mode on. - `boto3_config`: The configuration for the boto3 client. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `guardrail_config`: Optional configuration for a guardrail that has been created in Amazon Bedrock. This must be provided as a dictionary matching either [GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html). @@ -1227,12 +1228,10 @@ Instance of `AmazonBedrockChatGenerator`. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes a synchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1248,7 +1247,8 @@ Supports both standard and streaming responses depending on whether a streaming - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tools that the model may call during execution. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: @@ -1265,11 +1265,10 @@ A dictionary containing the model-generated replies under the `"replies"` key. ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes an asynchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1285,7 +1284,8 @@ Designed for use cases where non-blocking or concurrent execution is desired. - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tool objects or a Toolset that the model can use. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/anthropic.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/anthropic.md index 4fadc67306..0ea96cf58f 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/anthropic.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/anthropic.md @@ -196,7 +196,7 @@ def __init__(api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), streaming_callback: Optional[StreamingCallbackT] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -231,7 +231,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. @@ -275,12 +276,10 @@ The deserialized component instance. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Invokes the Anthropic API with the given messages and generation kwargs. @@ -290,8 +289,9 @@ Invokes the Anthropic API with the given messages and generation kwargs. - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -305,11 +305,10 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Async version of the run method. Invokes the Anthropic API with the given messages and generation kwargs. @@ -319,8 +318,9 @@ Async version of the run method. Invokes the Anthropic API with the given messag - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -392,7 +392,7 @@ def __init__(region: str, None]] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[List[Tool]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -425,7 +425,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/cohere.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/cohere.md index 8e1c14fb52..5062839bef 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/cohere.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/cohere.md @@ -745,7 +745,7 @@ def __init__(api_key: Secret = Secret.from_env_var( streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = None, generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, **kwargs: Any) ``` @@ -770,7 +770,8 @@ Some of the parameters are: `accurate` results or `fast` results. - 'temperature': A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset that the model can use. +Each tool should have a unique name. @@ -814,7 +815,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -828,8 +829,8 @@ Invoke the chat endpoint based on the provided messages and generation parameter potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. @@ -847,7 +848,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -861,8 +862,8 @@ Asynchronously invoke the chat endpoint based on the provided messages and gener potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. **Returns**: diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/google_genai.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/google_genai.md index bd51dae768..e9cc647592 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/google_genai.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/google_genai.md @@ -131,7 +131,7 @@ def __init__(*, generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) + tools: Optional[ToolsType] = None) ``` Initialize a GoogleGenAIChatGenerator instance. @@ -156,7 +156,8 @@ For Gemini 2.5 series, supports `thinking_budget` to configure thinking behavior - Positive integer: Set explicit budget - `safety_settings`: Safety settings for content filtering - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. @@ -201,7 +202,7 @@ def run(messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Run the Google Gen AI chat generator on the given input data. @@ -215,8 +216,8 @@ the default config. Supports `thinking_budget` for Gemini 2.5 series thinking co default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: @@ -235,12 +236,11 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) -async def run_async( - messages: List[ChatMessage], - generation_kwargs: Optional[Dict[str, Any]] = None, - safety_settings: Optional[List[Dict[str, Any]]] = None, - streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] +async def run_async(messages: List[ChatMessage], + generation_kwargs: Optional[Dict[str, Any]] = None, + safety_settings: Optional[List[Dict[str, Any]]] = None, + streaming_callback: Optional[StreamingCallbackT] = None, + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Async version of the run method. Run the Google Gen AI chat generator on the given input data. @@ -255,8 +255,8 @@ See https://ai.google.dev/gemini-api/docs/thinking for possible values. default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/mcp.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/mcp.md index fb75acbede..73471fc22c 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/mcp.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/mcp.md @@ -673,7 +673,8 @@ def __init__(name: str, server_info: MCPServerInfo, description: str | None = None, connection_timeout: int = 30, - invocation_timeout: int = 30) + invocation_timeout: int = 30, + eager_connect: bool = False) ``` Initialize the MCP tool. @@ -685,6 +686,9 @@ Initialize the MCP tool. - `description`: Custom description (if None, server description will be used) - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server during initialization. +If False (default), defer connection until warm_up or first tool use, +whichever comes first. **Raises**: @@ -715,6 +719,16 @@ Asynchronous tool invocation. JSON string representation of the tool invocation result + + +#### MCPTool.warm\_up + +```python +def warm_up() -> None +``` + +Connect and fetch the tool schema if eager_connect is turned off. + #### MCPTool.to\_dict @@ -792,20 +806,6 @@ def tool_spec() -> dict[str, Any] Return the Tool specification to be used by the Language Model. - - -#### MCPTool.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Tool for use. - -Override this method to establish connections to remote services, load models, -or perform other resource-intensive initialization. This method should be idempotent, -as it may be called multiple times. - #### MCPTool.invoke @@ -953,7 +953,8 @@ sse_toolset = MCPToolset( def __init__(server_info: MCPServerInfo, tool_names: list[str] | None = None, connection_timeout: float = 30.0, - invocation_timeout: float = 30.0) + invocation_timeout: float = 30.0, + eager_connect: bool = False) ``` Initialize the MCP toolset. @@ -965,11 +966,27 @@ Initialize the MCP toolset. matching names will be added to the toolset. - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server and load tools during initialization. +If False (default), defer connection to warm_up. **Raises**: - `MCPToolNotFoundError`: If any of the specified tool names are not found on the server + + +#### MCPToolset.warm\_up + +```python +def warm_up() -> None +``` + +Connect and load tools when eager_connect is turned off. + +This method is automatically called by ``ToolInvoker.warm_up()`` and ``Pipeline.warm_up()``. +You can also call it directly before using the toolset to ensure all tool schemas +are available without performing a real invocation. + #### MCPToolset.to\_dict @@ -1063,19 +1080,6 @@ Supports checking by: True if contained, False otherwise - - -#### MCPToolset.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Toolset for use. - -Override this method to set up shared resources like database connections or HTTP sessions. -This method should be idempotent, as it may be called multiple times. - #### MCPToolset.add diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/mistral.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/mistral.md index 432d8380f7..758ca5d2a8 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/mistral.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/mistral.md @@ -382,8 +382,8 @@ Some of the supported parameters: Notes: - For structured outputs with streaming, the `response_format` must be a JSON schema and not a Pydantic model. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Mistral API call. If not set, it defaults to either the `OPENAI_TIMEOUT` environment variable, or 30 seconds. - `max_retries`: Maximum number of retries to contact OpenAI after an internal error. diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/ollama.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/ollama.md index 1ba5c76aca..eefffbd938 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/ollama.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/ollama.md @@ -165,7 +165,7 @@ def __init__(model: str = "qwen3:0.6b", keep_alive: Optional[Union[float, str]] = None, streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, response_format: Optional[Union[None, Literal["json"], JsonSchemaValue]] = None, think: Union[bool, Literal["low", "medium", "high"]] = False) @@ -200,9 +200,9 @@ The name of the model to use. The model must already be present (pulled) in the A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. :param tools: - A list of `haystack.tools.Tool` or a `haystack.tools.Toolset`. Duplicate tool names raise a `ValueError`. - Not all models support tools. For a list of models compatible with tools, see the - [models page](https://ollama.com/search?c=tools). + A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. + Each tool should have a unique name. Not all models support tools. For a list of models compatible + with tools, see the [models page](https://ollama.com/search?c=tools). :param response_format: The format for structured model outputs. The value can be: - None: No specific structure or format is applied to the response. The response is returned as-is. @@ -253,7 +253,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -268,9 +268,8 @@ Runs an Ollama Model on a given chat history. These are merged on top of the instance-level `generation_kwargs`. Optional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the [Ollama docs](https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. If set, it will override the `tools` parameter set -during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback (here or in the constructor) switches the component into streaming mode. @@ -289,7 +288,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -302,7 +301,7 @@ Async version of run. Runs an Ollama Model on a given chat history. - `messages`: A list of ChatMessage instances representing the input messages. - `generation_kwargs`: Per-call overrides for Ollama inference options. These are merged on top of the instance-level `generation_kwargs`. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback switches the component into streaming mode. diff --git a/docs-website/reference_versioned_docs/version-2.18/qdrant.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/qdrant.md similarity index 99% rename from docs-website/reference_versioned_docs/version-2.18/qdrant.md rename to docs-website/reference_versioned_docs/version-2.18/integrations-api/qdrant.md index 2d9436ce42..6846a84d13 100644 --- a/docs-website/reference_versioned_docs/version-2.18/qdrant.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/qdrant.md @@ -1038,4 +1038,3 @@ new_document_store = QdrantDocumentStore(url="http://localhost:6333", - `old_document_store`: The existing QdrantDocumentStore instance to migrate from. - `new_index`: The name of the new index/collection to create with sparse embeddings support. - diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/snowflake.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/snowflake.md index 064d8a9e5c..45e4f73551 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/snowflake.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/snowflake.md @@ -32,6 +32,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Key-pair Authentication (MFA): @@ -46,6 +47,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### OAuth Authentication (MFA): @@ -61,6 +63,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Running queries: @@ -93,17 +96,23 @@ shape: (3, 3) ```python def __init__(user: str, account: str, - authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", "OAUTH"], - api_key: Optional[Secret] = None, + authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", + "OAUTH"] = "SNOWFLAKE", + api_key: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_API_KEY", strict=False), database: Optional[str] = None, db_schema: Optional[str] = None, warehouse: Optional[str] = None, login_timeout: Optional[int] = 60, return_markdown: bool = True, - private_key_file: Optional[Secret] = None, - private_key_file_pwd: Optional[Secret] = None, - oauth_client_id: Optional[Secret] = None, - oauth_client_secret: Optional[Secret] = None, + private_key_file: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_FILE", strict=False), + private_key_file_pwd: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_PWD", strict=False), + oauth_client_id: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_ID", strict=False), + oauth_client_secret: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_SECRET", strict=False), oauth_token_request_url: Optional[str] = None, oauth_authorization_url: Optional[str] = None) -> None ``` @@ -131,19 +140,15 @@ Required for OAUTH authentication. - `oauth_token_request_url`: OAuth token request URL for Client Credentials flow. - `oauth_authorization_url`: OAuth authorization URL for Authorization Code flow. - + -#### SnowflakeTableRetriever.test\_connection +#### SnowflakeTableRetriever.warm\_up ```python -def test_connection() -> bool +def warm_up() -> None ``` -Tests the connection with the current authentication settings. - -**Returns**: - -True if connection is successful, False otherwise. +Warm up the component by initializing the authenticator handler and testing the database connection. diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/together_ai.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/together_ai.md index 8610d1ce98..5282c17ea3 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/together_ai.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/together_ai.md @@ -231,7 +231,7 @@ def __init__(*, streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = "https://api.together.xyz/v1", generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, timeout: Optional[float] = None, max_retries: Optional[int] = None, http_client_kwargs: Optional[Dict[str, Any]] = None) @@ -263,8 +263,8 @@ Some of the supported parameters: events as they become available, with the stream terminated by a data: [DONE] message. - `safe_prompt`: Whether to inject a safety prompt before all conversations. - `random_seed`: The seed to use for random sampling. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Together AI API call. - `max_retries`: Maximum number of retries to contact Together AI after an internal error. If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5. diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/amazon_bedrock.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/amazon_bedrock.md index 5bb9645dc5..a9383e8173 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/amazon_bedrock.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/amazon_bedrock.md @@ -1135,7 +1135,7 @@ def __init__( generation_kwargs: Optional[Dict[str, Any]] = None, streaming_callback: Optional[StreamingCallbackT] = None, boto3_config: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, guardrail_config: Optional[Dict[str, str]] = None) -> None ``` @@ -1168,7 +1168,8 @@ function that handles the streaming chunks. The callback function receives a [StreamingChunk](https://docs.haystack.deepset.ai/docs/data-classes#streamingchunk) object and switches the streaming mode on. - `boto3_config`: The configuration for the boto3 client. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `guardrail_config`: Optional configuration for a guardrail that has been created in Amazon Bedrock. This must be provided as a dictionary matching either [GuardrailConfiguration](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GuardrailConfiguration.html). @@ -1227,12 +1228,10 @@ Instance of `AmazonBedrockChatGenerator`. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes a synchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1248,7 +1247,8 @@ Supports both standard and streaming responses depending on whether a streaming - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tools that the model may call during execution. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: @@ -1265,11 +1265,10 @@ A dictionary containing the model-generated replies under the `"replies"` key. ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Executes an asynchronous inference call to the Amazon Bedrock model using the Converse API. @@ -1285,7 +1284,8 @@ Designed for use cases where non-blocking or concurrent execution is desired. - `stopSequences`: List of stop sequences to stop generation. - `temperature`: Sampling temperature. - `topP`: Nucleus sampling parameter. -- `tools`: Optional list of Tool objects or a Toolset that the model can use. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/anthropic.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/anthropic.md index 4fadc67306..0ea96cf58f 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/anthropic.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/anthropic.md @@ -196,7 +196,7 @@ def __init__(api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), streaming_callback: Optional[StreamingCallbackT] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -231,7 +231,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. @@ -275,12 +276,10 @@ The deserialized component instance. ```python @component.output_types(replies=List[ChatMessage]) -def run( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] +def run(messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Invokes the Anthropic API with the given messages and generation kwargs. @@ -290,8 +289,9 @@ Invokes the Anthropic API with the given messages and generation kwargs. - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -305,11 +305,10 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) async def run_async( - messages: List[ChatMessage], - streaming_callback: Optional[StreamingCallbackT] = None, - generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None -) -> Dict[str, List[ChatMessage]] + messages: List[ChatMessage], + streaming_callback: Optional[StreamingCallbackT] = None, + generation_kwargs: Optional[Dict[str, Any]] = None, + tools: Optional[ToolsType] = None) -> Dict[str, List[ChatMessage]] ``` Async version of the run method. Invokes the Anthropic API with the given messages and generation kwargs. @@ -319,8 +318,9 @@ Async version of the run method. Invokes the Anthropic API with the given messag - `messages`: A list of ChatMessage instances representing the input messages. - `streaming_callback`: A callback function that is called when a new token is received from the stream. - `generation_kwargs`: Optional arguments to pass to the Anthropic generation endpoint. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should -have a unique name. If set, it will override the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. If set, it will override the `tools` parameter set during component +initialization. **Returns**: @@ -392,7 +392,7 @@ def __init__(region: str, None]] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, - tools: Optional[List[Tool]] = None, + tools: Optional[ToolsType] = None, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) @@ -425,7 +425,8 @@ Supported generation_kwargs parameters are: `ignore_tools_thinking_messages` is `True`, the generator will drop so-called thinking messages when tool use is detected. See the Anthropic [tools](https://docs.anthropic.com/en/docs/tool-use#chain-of-thought-tool-use) for more details. -- `tools`: A list of Tool objects that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset, that the model can use. +Each tool should have a unique name. - `timeout`: Timeout for Anthropic client calls. If not set, it defaults to the default set by the Anthropic client. - `max_retries`: Maximum number of retries to attempt for failed requests. If not set, it defaults to the default set by the Anthropic client. diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/cohere.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/cohere.md index 8e1c14fb52..5062839bef 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/cohere.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/cohere.md @@ -745,7 +745,7 @@ def __init__(api_key: Secret = Secret.from_env_var( streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = None, generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, **kwargs: Any) ``` @@ -770,7 +770,8 @@ Some of the parameters are: `accurate` results or `fast` results. - 'temperature': A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset that the model can use. +Each tool should have a unique name. @@ -814,7 +815,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -828,8 +829,8 @@ Invoke the chat endpoint based on the provided messages and generation parameter potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. @@ -847,7 +848,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] ``` @@ -861,8 +862,8 @@ Asynchronously invoke the chat endpoint based on the provided messages and gener potentially override the parameters passed in the __init__ method. For more details on the parameters supported by the Cohere API, refer to the Cohere [documentation](https://docs.cohere.com/reference/chat). -- `tools`: A list of tools for which the model can prepare calls. If set, it will override -the `tools` parameter set during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callback function that is called when a new token is received from the stream. **Returns**: diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/google_genai.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/google_genai.md index bd51dae768..e9cc647592 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/google_genai.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/google_genai.md @@ -131,7 +131,7 @@ def __init__(*, generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) + tools: Optional[ToolsType] = None) ``` Initialize a GoogleGenAIChatGenerator instance. @@ -156,7 +156,8 @@ For Gemini 2.5 series, supports `thinking_budget` to configure thinking behavior - Positive integer: Set explicit budget - `safety_settings`: Safety settings for content filtering - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. Each tool should have a unique name. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. @@ -201,7 +202,7 @@ def run(messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, safety_settings: Optional[List[Dict[str, Any]]] = None, streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Run the Google Gen AI chat generator on the given input data. @@ -215,8 +216,8 @@ the default config. Supports `thinking_budget` for Gemini 2.5 series thinking co default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: @@ -235,12 +236,11 @@ A dictionary with the following keys: ```python @component.output_types(replies=List[ChatMessage]) -async def run_async( - messages: List[ChatMessage], - generation_kwargs: Optional[Dict[str, Any]] = None, - safety_settings: Optional[List[Dict[str, Any]]] = None, - streaming_callback: Optional[StreamingCallbackT] = None, - tools: Optional[Union[List[Tool], Toolset]] = None) -> Dict[str, Any] +async def run_async(messages: List[ChatMessage], + generation_kwargs: Optional[Dict[str, Any]] = None, + safety_settings: Optional[List[Dict[str, Any]]] = None, + streaming_callback: Optional[StreamingCallbackT] = None, + tools: Optional[ToolsType] = None) -> Dict[str, Any] ``` Async version of the run method. Run the Google Gen AI chat generator on the given input data. @@ -255,8 +255,8 @@ See https://ai.google.dev/gemini-api/docs/thinking for possible values. default settings. - `streaming_callback`: A callback function that is called when a new token is received from the stream. -- `tools`: A list of Tool objects or a Toolset that the model can use. If provided, it will -override the tools set during initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If provided, it will override the tools set during initialization. **Raises**: diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/mcp.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/mcp.md index fb75acbede..73471fc22c 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/mcp.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/mcp.md @@ -673,7 +673,8 @@ def __init__(name: str, server_info: MCPServerInfo, description: str | None = None, connection_timeout: int = 30, - invocation_timeout: int = 30) + invocation_timeout: int = 30, + eager_connect: bool = False) ``` Initialize the MCP tool. @@ -685,6 +686,9 @@ Initialize the MCP tool. - `description`: Custom description (if None, server description will be used) - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server during initialization. +If False (default), defer connection until warm_up or first tool use, +whichever comes first. **Raises**: @@ -715,6 +719,16 @@ Asynchronous tool invocation. JSON string representation of the tool invocation result + + +#### MCPTool.warm\_up + +```python +def warm_up() -> None +``` + +Connect and fetch the tool schema if eager_connect is turned off. + #### MCPTool.to\_dict @@ -792,20 +806,6 @@ def tool_spec() -> dict[str, Any] Return the Tool specification to be used by the Language Model. - - -#### MCPTool.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Tool for use. - -Override this method to establish connections to remote services, load models, -or perform other resource-intensive initialization. This method should be idempotent, -as it may be called multiple times. - #### MCPTool.invoke @@ -953,7 +953,8 @@ sse_toolset = MCPToolset( def __init__(server_info: MCPServerInfo, tool_names: list[str] | None = None, connection_timeout: float = 30.0, - invocation_timeout: float = 30.0) + invocation_timeout: float = 30.0, + eager_connect: bool = False) ``` Initialize the MCP toolset. @@ -965,11 +966,27 @@ Initialize the MCP toolset. matching names will be added to the toolset. - `connection_timeout`: Timeout in seconds for server connection - `invocation_timeout`: Default timeout in seconds for tool invocations +- `eager_connect`: If True, connect to server and load tools during initialization. +If False (default), defer connection to warm_up. **Raises**: - `MCPToolNotFoundError`: If any of the specified tool names are not found on the server + + +#### MCPToolset.warm\_up + +```python +def warm_up() -> None +``` + +Connect and load tools when eager_connect is turned off. + +This method is automatically called by ``ToolInvoker.warm_up()`` and ``Pipeline.warm_up()``. +You can also call it directly before using the toolset to ensure all tool schemas +are available without performing a real invocation. + #### MCPToolset.to\_dict @@ -1063,19 +1080,6 @@ Supports checking by: True if contained, False otherwise - - -#### MCPToolset.warm\_up - -```python -def warm_up() -> None -``` - -Prepare the Toolset for use. - -Override this method to set up shared resources like database connections or HTTP sessions. -This method should be idempotent, as it may be called multiple times. - #### MCPToolset.add diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/mistral.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/mistral.md index 432d8380f7..758ca5d2a8 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/mistral.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/mistral.md @@ -382,8 +382,8 @@ Some of the supported parameters: Notes: - For structured outputs with streaming, the `response_format` must be a JSON schema and not a Pydantic model. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Mistral API call. If not set, it defaults to either the `OPENAI_TIMEOUT` environment variable, or 30 seconds. - `max_retries`: Maximum number of retries to contact OpenAI after an internal error. diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/ollama.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/ollama.md index 1ba5c76aca..eefffbd938 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/ollama.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/ollama.md @@ -165,7 +165,7 @@ def __init__(model: str = "qwen3:0.6b", keep_alive: Optional[Union[float, str]] = None, streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, response_format: Optional[Union[None, Literal["json"], JsonSchemaValue]] = None, think: Union[bool, Literal["low", "medium", "high"]] = False) @@ -200,9 +200,9 @@ The name of the model to use. The model must already be present (pulled) in the A callback function that is called when a new token is received from the stream. The callback function accepts StreamingChunk as an argument. :param tools: - A list of `haystack.tools.Tool` or a `haystack.tools.Toolset`. Duplicate tool names raise a `ValueError`. - Not all models support tools. For a list of models compatible with tools, see the - [models page](https://ollama.com/search?c=tools). + A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. + Each tool should have a unique name. Not all models support tools. For a list of models compatible + with tools, see the [models page](https://ollama.com/search?c=tools). :param response_format: The format for structured model outputs. The value can be: - None: No specific structure or format is applied to the response. The response is returned as-is. @@ -253,7 +253,7 @@ Deserialized component. def run( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -268,9 +268,8 @@ Runs an Ollama Model on a given chat history. These are merged on top of the instance-level `generation_kwargs`. Optional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the [Ollama docs](https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values). -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. If set, it will override the `tools` parameter set -during component initialization. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback (here or in the constructor) switches the component into streaming mode. @@ -289,7 +288,7 @@ A dictionary with the following keys: async def run_async( messages: List[ChatMessage], generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, *, streaming_callback: Optional[StreamingCallbackT] = None ) -> Dict[str, List[ChatMessage]] @@ -302,7 +301,7 @@ Async version of run. Runs an Ollama Model on a given chat history. - `messages`: A list of ChatMessage instances representing the input messages. - `generation_kwargs`: Per-call overrides for Ollama inference options. These are merged on top of the instance-level `generation_kwargs`. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. If set, it will override the `tools` parameter set during component initialization. - `streaming_callback`: A callable to receive `StreamingChunk` objects as they arrive. Supplying a callback switches the component into streaming mode. diff --git a/docs-website/reference_versioned_docs/version-2.19/qdrant.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/qdrant.md similarity index 99% rename from docs-website/reference_versioned_docs/version-2.19/qdrant.md rename to docs-website/reference_versioned_docs/version-2.19/integrations-api/qdrant.md index 2d9436ce42..6846a84d13 100644 --- a/docs-website/reference_versioned_docs/version-2.19/qdrant.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/qdrant.md @@ -1038,4 +1038,3 @@ new_document_store = QdrantDocumentStore(url="http://localhost:6333", - `old_document_store`: The existing QdrantDocumentStore instance to migrate from. - `new_index`: The name of the new index/collection to create with sparse embeddings support. - diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/snowflake.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/snowflake.md index 064d8a9e5c..45e4f73551 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/snowflake.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/snowflake.md @@ -32,6 +32,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Key-pair Authentication (MFA): @@ -46,6 +47,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### OAuth Authentication (MFA): @@ -61,6 +63,7 @@ executor = SnowflakeTableRetriever( db_schema="", warehouse="", ) +executor.warm_up() ``` #### Running queries: @@ -93,17 +96,23 @@ shape: (3, 3) ```python def __init__(user: str, account: str, - authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", "OAUTH"], - api_key: Optional[Secret] = None, + authenticator: Literal["SNOWFLAKE", "SNOWFLAKE_JWT", + "OAUTH"] = "SNOWFLAKE", + api_key: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_API_KEY", strict=False), database: Optional[str] = None, db_schema: Optional[str] = None, warehouse: Optional[str] = None, login_timeout: Optional[int] = 60, return_markdown: bool = True, - private_key_file: Optional[Secret] = None, - private_key_file_pwd: Optional[Secret] = None, - oauth_client_id: Optional[Secret] = None, - oauth_client_secret: Optional[Secret] = None, + private_key_file: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_FILE", strict=False), + private_key_file_pwd: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_PRIVATE_KEY_PWD", strict=False), + oauth_client_id: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_ID", strict=False), + oauth_client_secret: Optional[Secret] = Secret.from_env_var( + "SNOWFLAKE_OAUTH_CLIENT_SECRET", strict=False), oauth_token_request_url: Optional[str] = None, oauth_authorization_url: Optional[str] = None) -> None ``` @@ -131,19 +140,15 @@ Required for OAUTH authentication. - `oauth_token_request_url`: OAuth token request URL for Client Credentials flow. - `oauth_authorization_url`: OAuth authorization URL for Authorization Code flow. - + -#### SnowflakeTableRetriever.test\_connection +#### SnowflakeTableRetriever.warm\_up ```python -def test_connection() -> bool +def warm_up() -> None ``` -Tests the connection with the current authentication settings. - -**Returns**: - -True if connection is successful, False otherwise. +Warm up the component by initializing the authenticator handler and testing the database connection. diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/together_ai.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/together_ai.md index 8610d1ce98..5282c17ea3 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/together_ai.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/together_ai.md @@ -231,7 +231,7 @@ def __init__(*, streaming_callback: Optional[StreamingCallbackT] = None, api_base_url: Optional[str] = "https://api.together.xyz/v1", generation_kwargs: Optional[Dict[str, Any]] = None, - tools: Optional[Union[List[Tool], Toolset]] = None, + tools: Optional[ToolsType] = None, timeout: Optional[float] = None, max_retries: Optional[int] = None, http_client_kwargs: Optional[Dict[str, Any]] = None) @@ -263,8 +263,8 @@ Some of the supported parameters: events as they become available, with the stream terminated by a data: [DONE] message. - `safe_prompt`: Whether to inject a safety prompt before all conversations. - `random_seed`: The seed to use for random sampling. -- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a -list of `Tool` objects or a `Toolset` instance. +- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls. +Each tool should have a unique name. - `timeout`: The timeout for the Together AI API call. - `max_retries`: Maximum number of retries to contact Together AI after an internal error. If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5.