langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper¶
- class langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper(*, region: Optional[str] = 'wt-wt', safesearch: str = 'moderate', time: Optional[str] = 'y', max_results: int = 5)[source]¶
Bases:
BaseModelWrapper for DuckDuckGo Search API.
Free and does not require any setup.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param max_results: int = 5¶
- param region: Optional[str] = 'wt-wt'¶
- param safesearch: str = 'moderate'¶
- param time: Optional[str] = 'y'¶
- get_snippets(query: str) List[str][source]¶
Run query through DuckDuckGo and return concatenated results.
- results(query: str, num_results: int, backend: str = 'api') List[Dict[str, str]][source]¶
Run query through DuckDuckGo and return metadata.
- Parameters
query – The query to search for.
num_results – The number of results to return.
- Returns
snippet - The description of the result. title - The title of the result. link - The link to the result.
- Return type
A list of dictionaries with the following keys