mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-30 18:33:40 +00:00
minor functionality change: adding API functionality to tavilysearch (#22761)
This commit is contained in:
parent
034257e9bf
commit
345fd3a556
@ -29,6 +29,19 @@ class TavilySearchResults(BaseTool):
|
|||||||
)
|
)
|
||||||
api_wrapper: TavilySearchAPIWrapper = Field(default_factory=TavilySearchAPIWrapper) # type: ignore[arg-type]
|
api_wrapper: TavilySearchAPIWrapper = Field(default_factory=TavilySearchAPIWrapper) # type: ignore[arg-type]
|
||||||
max_results: int = 5
|
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
|
args_schema: Type[BaseModel] = TavilyInput
|
||||||
|
|
||||||
def _run(
|
def _run(
|
||||||
@ -41,6 +54,12 @@ class TavilySearchResults(BaseTool):
|
|||||||
return self.api_wrapper.results(
|
return self.api_wrapper.results(
|
||||||
query,
|
query,
|
||||||
self.max_results,
|
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:
|
except Exception as e:
|
||||||
return repr(e)
|
return repr(e)
|
||||||
@ -55,6 +74,12 @@ class TavilySearchResults(BaseTool):
|
|||||||
return await self.api_wrapper.results_async(
|
return await self.api_wrapper.results_async(
|
||||||
query,
|
query,
|
||||||
self.max_results,
|
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:
|
except Exception as e:
|
||||||
return repr(e)
|
return repr(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user