From 003fd263fad7efbc2edbc93b32bbcf883165ffc8 Mon Sep 17 00:00:00 2001 From: Haystack Bot <73523382+HaystackBot@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:33:00 +0200 Subject: [PATCH] docs: sync Core Integrations API reference (tavily) on Docusaurus (#12013) Co-authored-by: anakin87 <44616784+anakin87@users.noreply.github.com> --- .../reference/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.18/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.19/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.20/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.21/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.22/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.23/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.24/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.25/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.26/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.27/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.28/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.29/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.30/integrations-api/tavily.md | 82 +++++++++++++++++++ .../version-2.31/integrations-api/tavily.md | 82 +++++++++++++++++++ 15 files changed, 1230 insertions(+) diff --git a/docs-website/reference/integrations-api/tavily.md b/docs-website/reference/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference/integrations-api/tavily.md +++ b/docs-website/reference/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.18/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.18/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.18/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.18/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.19/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.19/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.19/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.19/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.20/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.20/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.20/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.20/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.21/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.21/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.21/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.21/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.22/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.22/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.22/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.22/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.23/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.23/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.23/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.23/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.24/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.24/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.24/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.24/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.25/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.25/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.25/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.25/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.26/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.26/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.26/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.26/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.27/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.27/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.27/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.27/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.28/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.28/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.28/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.28/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.29/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.29/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.29/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.29/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.30/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.30/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.30/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.30/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool. diff --git a/docs-website/reference_versioned_docs/version-2.31/integrations-api/tavily.md b/docs-website/reference_versioned_docs/version-2.31/integrations-api/tavily.md index 2bf711993c..1c8dd90c89 100644 --- a/docs-website/reference_versioned_docs/version-2.31/integrations-api/tavily.md +++ b/docs-website/reference_versioned_docs/version-2.31/integrations-api/tavily.md @@ -217,3 +217,85 @@ Asynchronously search the web using Tavily and return results as Documents. - dict\[str, Any\] – A dictionary with: - `documents`: List of Documents containing search result content. - `links`: List of URLs from the search results. + +## haystack_integrations.tools.tavily.websearch_tool + +### TavilyWebSearchTool + +Bases: ComponentTool + +A tool that searches the web with Tavily. + +Wraps the `TavilyWebSearch` component and formats its results as a string that an LLM can cite. +The tool parameters are derived from the component's `run` method, so the LLM can pass a `query` and, +optionally, `search_params` overriding the ones set at initialization time. + +### Usage example + +```python +from haystack.components.agents import Agent +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack_integrations.tools.tavily import TavilyWebSearchTool + +web_search = TavilyWebSearchTool(top_k=5, search_params={"search_depth": "advanced"}) + +agent = Agent(chat_generator=OpenAIChatGenerator(model="gpt-5-mini"), tools=[web_search]) + +result = agent.run(messages=[ChatMessage.from_user("What is Haystack by deepset?")]) +print(result["last_message"].text) +``` + +#### __init__ + +```python +__init__( + *, + api_key: Secret | None = None, + top_k: int | None = None, + search_params: dict[str, Any] | None = None, + name: str = "web_search", + description: str = _DEFAULT_DESCRIPTION +) -> None +``` + +Initialize the TavilyWebSearchTool. + +**Parameters:** + +- **api_key** (Secret | None) – API key for Tavily. If unset, `TavilyWebSearch` reads the `TAVILY_API_KEY` environment variable. +- **top_k** (int | None) – Maximum number of results to return. If unset, the `TavilyWebSearch` default applies. +- **search_params** (dict\[str, Any\] | None) – Additional parameters passed to the Tavily search API. + See the [Tavily API reference](https://docs.tavily.com/docs/tavily-api/rest_api) + for available options. Supported keys include: `search_depth`, `include_answer`, + `include_raw_content`, `include_domains`, `exclude_domains`. +- **name** (str) – Tool name exposed to the LLM. +- **description** (str) – Tool description exposed to the LLM. + +#### to_dict + +```python +to_dict() -> dict[str, Any] +``` + +Serialize the tool to a dictionary. + +**Returns:** + +- dict\[str, Any\] – Dictionary with serialized data. + +#### from_dict + +```python +from_dict(data: dict[str, Any]) -> TavilyWebSearchTool +``` + +Deserialize the tool from a dictionary. + +**Parameters:** + +- **data** (dict\[str, Any\]) – Dictionary to deserialize from. + +**Returns:** + +- TavilyWebSearchTool – Deserialized tool.