mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
54adcd9e82
We add a tool and retriever for the [AskNews](https://asknews.app) platform with example notebooks. The retriever can be invoked with: ```py from langchain_community.retrievers import AskNewsRetriever retriever = AskNewsRetriever(k=3) retriever.invoke("impact of fed policy on the tech sector") ``` To retrieve 3 documents in then news related to fed policy impacts on the tech sector. The included notebook also includes deeper details about controlling filters such as category and time, as well as including the retriever in a chain. The tool is quite interesting, as it allows the agent to decide how to obtain the news by forming a query and deciding how far back in time to look for the news: ```py from langchain_community.tools.asknews import AskNewsSearch from langchain import hub from langchain.agents import AgentExecutor, create_openai_functions_agent from langchain_openai import ChatOpenAI tool = AskNewsSearch() instructions = """You are an assistant.""" base_prompt = hub.pull("langchain-ai/openai-functions-template") prompt = base_prompt.partial(instructions=instructions) llm = ChatOpenAI(temperature=0) asknews_tool = AskNewsSearch() tools = [asknews_tool] agent = create_openai_functions_agent(llm, tools, prompt) agent_executor = AgentExecutor( agent=agent, tools=tools, verbose=True, ) agent_executor.invoke({"input": "How is the tech sector being affected by fed policy?"}) ``` --------- Co-authored-by: Emre <e@emre.pm>
152 lines
3.8 KiB
Python
152 lines
3.8 KiB
Python
"""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",
|
|
"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)
|