c56bef871b
Sync docs with Docusaurus / sync (push) Waiting to run
Tests / Check if changed (push) Waiting to run
Tests / format (push) Blocked by required conditions
Tests / check-imports (push) Blocked by required conditions
Tests / Unit / macos-latest (push) Blocked by required conditions
Tests / Unit / ubuntu-latest (push) Blocked by required conditions
Tests / Unit / windows-latest (push) Blocked by required conditions
Tests / mypy (push) Blocked by required conditions
Tests / Integration / ubuntu-latest (push) Blocked by required conditions
Tests / Integration / macos-latest (push) Blocked by required conditions
Tests / Integration / windows-latest (push) Blocked by required conditions
Tests / notify-slack-on-failure (push) Blocked by required conditions
Tests / Mark tests as completed (push) Blocked by required conditions
Docker image release / Build base image (push) Waiting to run
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
3.0 KiB
3.0 KiB
title, id, description, slug
| title | id | description | slug |
|---|---|---|---|
| Brave Search | integrations-brave | Brave Search integration for Haystack | /integrations-brave |
haystack_integrations.components.websearch.brave.brave_websearch
BraveWebSearch
A component that uses the Brave Search API to search the web and return results as Haystack Documents.
You need a Brave Search API key from brave.com/search/api.
Usage example
from haystack_integrations.components.websearch.brave import BraveWebSearch
from haystack.utils import Secret
websearch = BraveWebSearch(
api_key=Secret.from_env_var("BRAVE_API_KEY"),
top_k=5,
)
result = websearch.run(query="What is Haystack by deepset?")
documents = result["documents"]
links = result["links"]
init
__init__(
api_key: Secret = Secret.from_env_var("BRAVE_API_KEY"),
top_k: int | None = 10,
country: str | None = None,
search_lang: str | None = None,
extra_params: dict[str, Any] | None = None,
timeout: int = 10,
max_retries: int = 3,
) -> None
Initialize the BraveWebSearch component.
Parameters:
- api_key (
Secret) – Brave Search API key. Defaults to theBRAVE_API_KEYenvironment variable. - top_k (
int | None) – Maximum number of results to return. Maps to thecountparameter in the Brave API. - country (
str | None) – 2-letter country code to bias search results (e.g."US","DE"). - search_lang (
str | None) – Language code for search results (e.g."en","de"). - extra_params (
dict[str, Any] | None) – Additional query parameters passed directly to the Brave Search API. - timeout (
int) – Timeout in seconds for the HTTP request. Defaults to 10. - max_retries (
int) – Maximum number of retry attempts on transient failures. Defaults to 3.
run
run(query: str, top_k: int | None = None) -> dict[str, Any]
Search the web using Brave Search and return results as Documents.
Parameters:
- query (
str) – Search query string. - top_k (
int | None) – Optional per-run override of the maximum number of results. If not provided, the init-timetop_kis used.
Returns:
dict[str, Any]– A dictionary with:documents: List of Documents containing search result content.links: List of URLs from the search results.
run_async
run_async(query: str, top_k: int | None = None) -> dict[str, Any]
Asynchronously search the web using Brave Search and return results as Documents.
Parameters:
- query (
str) – Search query string. - top_k (
int | None) – Optional per-run override of the maximum number of results. If not provided, the init-timetop_kis used.
Returns:
dict[str, Any]– A dictionary with:documents: List of Documents containing search result content.links: List of URLs from the search results.