Toolkits
Camel.toolkits.searxng toolkit
SearxNGToolkit
A toolkit for performing web searches using SearxNG search engine.
This toolkit provides methods to search the web using SearxNG, a privacy-respecting metasearch engine. It supports customizable search parameters and safe search levels.
Parameters:
- searxng_host (str): The URL of the SearxNG instance to use for searches. Must be a valid HTTP/HTTPS URL.
- language (str, optional): Search language code for results. (default: :obj:
"en"
) - categories (List[str], optional): List of search categories to use. (default: :obj:
None
) - time_range (str, optional): Time range filter for search results.Valid values are “day”, “week”, “month”, “year”. (default: :obj:
None
) - safe_search (int, optional): Safe search level (0: None, 1: Moderate, 2: Strict). (default: :obj:
1
) - timeout (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:
None
)
init
_validate_searxng_host
Validate if the given URL is a proper HTTP/HTTPS URL.
Parameters:
- url (str): The URL to validate.
_validate_safe_search
Validate if the safe search level is valid.
Parameters:
- level (int): The safe search level to validate.
_validate_time_range
Validate if the time range is valid.
Parameters:
- time_range (str): The time range to validate.
search
Perform a web search using the configured SearxNG instance.
Parameters:
- query (str): The search query string to execute.
- num_results (int, optional): Maximum number of results to return. (default: :obj:
10
) - category (str, optional): Specific search category to use. If not provided, uses the first category from self.categories. (default: :obj:
None
)
Returns:
List[Dict[str, str]]: List of search results, where each result is dictionary containing ‘title’, ‘link’, and ‘snippet’ keys.
get_tools
Returns:
List[FunctionTool]: A list of FunctionTool objects representing the available functions in the toolkit.