langchain_community.utilities.metaphor_search
.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: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None, start_crawl_date: Optional[str] = None, end_crawl_date: Optional[str] = None, start_published_date: Optional[str] = None, end_published_date: Optional[str] = None, use_autoprompt: Optional[bool] = 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 (Optional[List[str]]) β A list of domains to include in the search. Only one of include_domains and exclude_domains should be defined.
exclude_domains (Optional[List[str]]) β A list of domains to exclude from the search. Only one of include_domains and exclude_domains should be defined.
start_crawl_date (Optional[str]) β If specified, only pages we crawled after start_crawl_date will be returned.
end_crawl_date (Optional[str]) β If specified, only pages we crawled before end_crawl_date will be returned.
start_published_date (Optional[str]) β If specified, only pages published after start_published_date will be returned.
end_published_date (Optional[str]) β If specified, only pages published before end_published_date will be returned.
use_autoprompt (Optional[bool]) β 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: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None, start_crawl_date: Optional[str] = None, end_crawl_date: Optional[str] = None, start_published_date: Optional[str] = None, end_published_date: Optional[str] = None, use_autoprompt: Optional[bool] = None) List[Dict] [source]ΒΆ
Get results from the Metaphor Search API asynchronously.
- Parameters
query (str) β
num_results (int) β
include_domains (Optional[List[str]]) β
exclude_domains (Optional[List[str]]) β
start_crawl_date (Optional[str]) β
end_crawl_date (Optional[str]) β
start_published_date (Optional[str]) β
end_published_date (Optional[str]) β
use_autoprompt (Optional[bool]) β
- Return type
List[Dict]