minor functionality change: adding API functionality to tavilysearch (#22761)

pull/22857/head
Isaac Francisco 4 months ago committed by GitHub
parent 034257e9bf
commit 345fd3a556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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)

Loading…
Cancel
Save