docs: standardizing tavily tool docs (#24736)

Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
Isaac Francisco
2024-08-02 15:25:27 -07:00
committed by GitHub
parent 2ae76cecde
commit 73570873ab
5 changed files with 285 additions and 265 deletions

View File

@@ -295,6 +295,10 @@ if TYPE_CHECKING:
from langchain_community.tools.steamship_image_generation import (
SteamshipImageGenerationTool,
)
from langchain_community.tools.tavily_search import (
TavilyAnswer,
TavilySearchResults,
)
from langchain_community.tools.vectorstore.tool import (
VectorStoreQATool,
VectorStoreQAWithSourcesTool,
@@ -450,6 +454,8 @@ __all__ = [
"SteamWebAPIQueryRun",
"SteamshipImageGenerationTool",
"StructuredTool",
"TavilyAnswer",
"TavilySearchResults",
"Tool",
"VectorStoreQATool",
"VectorStoreQAWithSourcesTool",
@@ -599,6 +605,8 @@ _module_lookup = {
"SteamWebAPIQueryRun": "langchain_community.tools.steam.tool",
"SteamshipImageGenerationTool": "langchain_community.tools.steamship_image_generation", # noqa: E501
"StructuredTool": "langchain_core.tools",
"TavilyAnswer": "langchain_community.tools.tavily_search",
"TavilySearchResults": "langchain_community.tools.tavily_search",
"Tool": "langchain_core.tools",
"VectorStoreQATool": "langchain_community.tools.vectorstore.tool",
"VectorStoreQAWithSourcesTool": "langchain_community.tools.vectorstore.tool",

View File

@@ -26,7 +26,7 @@ class TavilySearchResults(BaseTool):
.. code-block:: bash
pip install -U langchain-openai
pip install -U langchain-community tavily-python
export TAVILY_API_KEY="your-api-key"
Instantiate:
@@ -53,7 +53,7 @@ class TavilySearchResults(BaseTool):
.. code-block:: python
'{\n "answer": "Novak Djokovic won the last French Open by beating Casper Ruud ...',
'{\n "url": "https://www.nytimes.com...", "content": "Novak Djokovic won the last French Open by beating Casper Ruud ...'
Invoke with tool call:
@@ -64,7 +64,7 @@ class TavilySearchResults(BaseTool):
.. code-block:: python
ToolMessage(
content='{\n "answer": "Novak Djokovic won the last French Open by beating Casper Ruud ...',
content='{\n "url": "https://www.nytimes.com...", "content": "Novak Djokovic won the last French Open by beating Casper Ruud ...',
artifact={
'query': 'who won the last french open',
'follow_up_questions': None,
@@ -103,17 +103,45 @@ class TavilySearchResults(BaseTool):
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"'''
"""The depth of the search. It can be "basic" or "advanced"
.. versionadded:: 0.2.5
"""
include_domains: List[str] = []
"""A list of domains to specifically include in the search results. Default is None, which includes all domains.""" # noqa: E501
"""A list of domains to specifically include in the search results.
Default is None, which includes all domains.
.. versionadded:: 0.2.5
"""
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
"""A list of domains to specifically exclude from the search results.
Default is None, which doesn't exclude any domains.
.. versionadded:: 0.2.5
"""
include_answer: bool = False
"""Include a short answer to original query in the search results. Default is False.""" # noqa: E501
"""Include a short answer to original query in the search results.
Default is False.
.. versionadded:: 0.2.5
"""
include_raw_content: bool = False
"""Include cleaned and parsed HTML of each site search results. Default is False."""
"""Include cleaned and parsed HTML of each site search results.
Default is False.
.. versionadded:: 0.2.5
"""
include_images: bool = False
"""Include a list of query related images in the response. Default is False."""
"""Include a list of query related images in the response.
Default is False.
.. versionadded:: 0.2.5
"""
api_wrapper: TavilySearchAPIWrapper = Field(default_factory=TavilySearchAPIWrapper) # type: ignore[arg-type]
response_format: Literal["content_and_artifact"] = "content_and_artifact"

View File

@@ -124,6 +124,8 @@ EXPECTED_ALL = [
"SteamWebAPIQueryRun",
"SteamshipImageGenerationTool",
"StructuredTool",
"TavilyAnswer",
"TavilySearchResults",
"Tool",
"VectorStoreQATool",
"VectorStoreQAWithSourcesTool",

View File

@@ -1,154 +0,0 @@
"""Test the public API of the tools package."""
from langchain_community.tools import __all__ as public_api
_EXPECTED = [
"AINAppOps",
"AINOwnerOps",
"AINRuleOps",
"AINTransfer",
"AINValueOps",
"AIPluginTool",
"APIOperation",
"ArxivQueryRun",
"AskNewsSearch",
"AzureAiServicesDocumentIntelligenceTool",
"AzureAiServicesImageAnalysisTool",
"AzureAiServicesSpeechToTextTool",
"AzureAiServicesTextToSpeechTool",
"AzureAiServicesTextAnalyticsForHealthTool",
"AzureCogsFormRecognizerTool",
"AzureCogsImageAnalysisTool",
"AzureCogsSpeech2TextTool",
"AzureCogsText2SpeechTool",
"AzureCogsTextAnalyticsHealthTool",
"BaseGraphQLTool",
"BaseRequestsTool",
"BaseSQLDatabaseTool",
"BaseSparkSQLTool",
"BaseTool",
"BearlyInterpreterTool",
"BingSearchResults",
"BingSearchRun",
"BraveSearch",
"ClickTool",
"CogniswitchKnowledgeSourceFile",
"CogniswitchKnowledgeStatus",
"CogniswitchKnowledgeSourceURL",
"CogniswitchKnowledgeRequest",
"ConneryAction",
"CopyFileTool",
"CurrentWebPageTool",
"DataheraldTextToSQL",
"DeleteFileTool",
"DuckDuckGoSearchResults",
"DuckDuckGoSearchRun",
"E2BDataAnalysisTool",
"EdenAiExplicitImageTool",
"EdenAiObjectDetectionTool",
"EdenAiParsingIDTool",
"EdenAiParsingInvoiceTool",
"EdenAiSpeechToTextTool",
"EdenAiTextModerationTool",
"EdenAiTextToSpeechTool",
"EdenaiTool",
"ElevenLabsText2SpeechTool",
"ExtractHyperlinksTool",
"ExtractTextTool",
"FileSearchTool",
"GetElementsTool",
"GmailCreateDraft",
"GmailGetMessage",
"GmailGetThread",
"GmailSearch",
"GmailSendMessage",
"GoogleCloudTextToSpeechTool",
"GooglePlacesTool",
"GoogleSearchResults",
"GoogleSearchRun",
"GoogleSerperResults",
"GoogleSerperRun",
"HumanInputRun",
"IFTTTWebhook",
"InfoPowerBITool",
"InfoSQLDatabaseTool",
"InfoSparkSQLTool",
"JiraAction",
"JsonGetValueTool",
"JsonListKeysTool",
"ListDirectoryTool",
"ListPowerBITool",
"ListSQLDatabaseTool",
"ListSparkSQLTool",
"MerriamWebsterQueryRun",
"MetaphorSearchResults",
"MoveFileTool",
"NasaAction",
"NavigateBackTool",
"NavigateTool",
"O365CreateDraftMessage",
"O365SearchEmails",
"O365SearchEvents",
"O365SendEvent",
"O365SendMessage",
"OpenAPISpec",
"OpenWeatherMapQueryRun",
"PubmedQueryRun",
"PolygonAggregates",
"PolygonFinancials",
"PolygonLastQuote",
"PolygonTickerNews",
"RedditSearchRun",
"RedditSearchSchema",
"QueryCheckerTool",
"QueryPowerBITool",
"QuerySQLCheckerTool",
"QuerySQLDataBaseTool",
"QuerySparkSQLTool",
"ReadFileTool",
"RequestsDeleteTool",
"RequestsGetTool",
"RequestsPatchTool",
"RequestsPostTool",
"RequestsPutTool",
"SceneXplainTool",
"SearchAPIResults",
"SearchAPIRun",
"SearxSearchResults",
"SearxSearchRun",
"ShellTool",
"SlackGetChannel",
"SlackGetMessage",
"SlackScheduleMessage",
"SlackSendMessage",
"SleepTool",
"StdInInquireTool",
"StackExchangeTool",
"SteamshipImageGenerationTool",
"StructuredTool",
"SteamWebAPIQueryRun",
"Tool",
"VectorStoreQATool",
"VectorStoreQAWithSourcesTool",
"WikipediaQueryRun",
"WolframAlphaQueryRun",
"WriteFileTool",
"YahooFinanceNewsTool",
"YouSearchTool",
"YouTubeSearchTool",
"ZapierNLAListActions",
"ZapierNLARunAction",
"Detector",
"ZenGuardInput",
"ZenGuardTool",
"authenticate",
"format_tool_to_openai_function",
"tool",
"MojeekSearch",
]
def test_public_api() -> None:
"""Test for regressions or changes in the public API."""
# Check that the public API is as expected
assert set(public_api) == set(_EXPECTED)