|
|
|
@ -29,6 +29,19 @@ class TavilySearchResults(BaseTool):
|
|
|
|
|
)
|
|
|
|
|
api_wrapper: TavilySearchAPIWrapper = Field(default_factory=TavilySearchAPIWrapper) # type: ignore[arg-type]
|
|
|
|
|
max_results: int = 5
|
|
|
|
|
"""Max search results to return, default is 5"""
|
|
|
|
|
search_depth: str = "advanced"
|
|
|
|
|
'''The depth of the search. It can be "basic" or "advanced"'''
|
|
|
|
|
include_domains: List[str] = []
|
|
|
|
|
"""A list of domains to specifically include in the search results. Default is None, which includes all domains.""" # noqa: E501
|
|
|
|
|
exclude_domains: List[str] = []
|
|
|
|
|
"""A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains.""" # noqa: E501
|
|
|
|
|
include_answer: bool = False
|
|
|
|
|
"""Include a short answer to original query in the search results. Default is False.""" # noqa: E501
|
|
|
|
|
include_raw_content: bool = False
|
|
|
|
|
"""Include cleaned and parsed HTML of each site search results. Default is False."""
|
|
|
|
|
include_images: bool = False
|
|
|
|
|
"""Include a list of query related images in the response. Default is False."""
|
|
|
|
|
args_schema: Type[BaseModel] = TavilyInput
|
|
|
|
|
|
|
|
|
|
def _run(
|
|
|
|
@ -41,6 +54,12 @@ class TavilySearchResults(BaseTool):
|
|
|
|
|
return self.api_wrapper.results(
|
|
|
|
|
query,
|
|
|
|
|
self.max_results,
|
|
|
|
|
self.search_depth,
|
|
|
|
|
self.include_domains,
|
|
|
|
|
self.exclude_domains,
|
|
|
|
|
self.include_answer,
|
|
|
|
|
self.include_raw_content,
|
|
|
|
|
self.include_images,
|
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return repr(e)
|
|
|
|
@ -55,6 +74,12 @@ class TavilySearchResults(BaseTool):
|
|
|
|
|
return await self.api_wrapper.results_async(
|
|
|
|
|
query,
|
|
|
|
|
self.max_results,
|
|
|
|
|
self.search_depth,
|
|
|
|
|
self.include_domains,
|
|
|
|
|
self.exclude_domains,
|
|
|
|
|
self.include_answer,
|
|
|
|
|
self.include_raw_content,
|
|
|
|
|
self.include_images,
|
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return repr(e)
|
|
|
|
|