MetaphorSearchAPIWrapper#
- class langchain_community.utilities.metaphor_search.MetaphorSearchAPIWrapper[source]#
Bases:
BaseModel
Wrapper for Metaphor Search API.
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 k: int = 10#
- param metaphor_api_key: str [Required]#
- results(query: str, num_results: int, include_domains: List[str] | None = None, exclude_domains: List[str] | None = None, start_crawl_date: str | None = None, end_crawl_date: str | None = None, start_published_date: str | None = None, end_published_date: str | None = None, use_autoprompt: bool | None = None) List[Dict] [source]#
Run query through Metaphor Search and return metadata.
- Parameters:
query (str) – The query to search for.
num_results (int) – The number of results to return.
include_domains (List[str] | None) – A list of domains to include in the search. Only one of include_domains and exclude_domains should be defined.
exclude_domains (List[str] | None) – A list of domains to exclude from the search. Only one of include_domains and exclude_domains should be defined.
start_crawl_date (str | None) – If specified, only pages we crawled after start_crawl_date will be returned.
end_crawl_date (str | None) – If specified, only pages we crawled before end_crawl_date will be returned.
start_published_date (str | None) – If specified, only pages published after start_published_date will be returned.
end_published_date (str | None) – If specified, only pages published before end_published_date will be returned.
use_autoprompt (bool | None) – If true, we turn your query into a more Metaphor-friendly query. Adds latency.
- Returns:
title - The title of the page url - The url author - Author of the content, if applicable. Otherwise, None. published_date - Estimated date published
in YYYY-MM-DD format. Otherwise, None.
- Return type:
A list of dictionaries with the following keys
- async results_async(query: str, num_results: int, include_domains: List[str] | None = None, exclude_domains: List[str] | None = None, start_crawl_date: str | None = None, end_crawl_date: str | None = None, start_published_date: str | None = None, end_published_date: str | None = None, use_autoprompt: bool | None = None) List[Dict] [source]#
Get results from the Metaphor Search API asynchronously.
- Parameters:
query (str) –
num_results (int) –
include_domains (List[str] | None) –
exclude_domains (List[str] | None) –
start_crawl_date (str | None) –
end_crawl_date (str | None) –
start_published_date (str | None) –
end_published_date (str | None) –
use_autoprompt (bool | None) –
- Return type:
List[Dict]