2023-05-02 02:07:26 +00:00
|
|
|
"""Test the public API of the tools package."""
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.tools import __all__ as public_api
|
2023-05-02 02:07:26 +00:00
|
|
|
|
|
|
|
_EXPECTED = [
|
2023-08-22 15:03:33 +00:00
|
|
|
"AINAppOps",
|
|
|
|
"AINOwnerOps",
|
|
|
|
"AINRuleOps",
|
|
|
|
"AINTransfer",
|
|
|
|
"AINValueOps",
|
2023-05-02 02:07:26 +00:00
|
|
|
"AIPluginTool",
|
|
|
|
"APIOperation",
|
2023-06-18 23:55:18 +00:00
|
|
|
"ArxivQueryRun",
|
2023-05-23 13:45:48 +00:00
|
|
|
"AzureCogsFormRecognizerTool",
|
|
|
|
"AzureCogsImageAnalysisTool",
|
|
|
|
"AzureCogsSpeech2TextTool",
|
|
|
|
"AzureCogsText2SpeechTool",
|
2023-11-20 02:44:01 +00:00
|
|
|
"AzureCogsTextAnalyticsHealthTool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"BaseGraphQLTool",
|
|
|
|
"BaseRequestsTool",
|
|
|
|
"BaseSQLDatabaseTool",
|
|
|
|
"BaseSparkSQLTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"BaseTool",
|
2023-10-31 21:58:09 +00:00
|
|
|
"BearlyInterpreterTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"BingSearchResults",
|
|
|
|
"BingSearchRun",
|
2023-06-18 23:55:18 +00:00
|
|
|
"BraveSearch",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ClickTool",
|
|
|
|
"CopyFileTool",
|
|
|
|
"CurrentWebPageTool",
|
|
|
|
"DeleteFileTool",
|
|
|
|
"DuckDuckGoSearchResults",
|
|
|
|
"DuckDuckGoSearchRun",
|
2023-10-31 21:58:09 +00:00
|
|
|
"E2BDataAnalysisTool",
|
Add EdenAI Tools (#9764)
This PR follows the Eden AI (LLM + embeddings) integration. #8633
We added different Tools to empower agents with new capabilities :
- text: explicit content detection
- image: explicit content detection
- image: object detection
- OCR: invoice parsing
- OCR: ID parsing
- audio: speech to text
- audio: text to speech
We plan to add more in the future (like translation, language detection,
+ others).
Usage:
```python
llm=EdenAI(feature="text",provider="openai", params={"temperature" : 0.2,"max_tokens" : 250})
tools = [
EdenAiTextModerationTool(providers=["openai"],language="en"),
EdenAiObjectDetectionTool(providers=["google","api4ai"]),
EdenAiTextToSpeechTool(providers=["amazon"],language="en",voice="MALE"),
EdenAiExplicitImageTool(providers=["amazon","google"]),
EdenAiSpeechToTextTool(providers=["amazon"]),
EdenAiParsingIDTool(providers=["amazon","klippa"],language="en"),
EdenAiParsingInvoiceTool(providers=["amazon","google"],language="en"),
]
agent_chain = initialize_agent(
tools,
llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
return_intermediate_steps=True,
)
result = agent_chain(""" i have this text : 'i want to slap you'
first : i want to know if this text contains explicit content or not .
second : if it does contain explicit content i want to know what is the explicit content in this text,
third : i want to make the text into speech .
if there is URL in the observations , you will always put it in the output (final answer) .
""")
```
output:
> Entering new AgentExecutor chain...
> I need to extract the information from the ID and then convert it to
text and then to speech
> Action: edenai_identity_parsing
> Action Input:
"https://www.citizencard.com/images/citizencard-uk-id-card-2023.jpg"
> Observation: last_name :
> value : ANGELA
> given_names :
> value : GREENE
> birth_place :
> birth_date :
> value : 2000-11-09
> issuance_date :
> expire_date :
> document_id :
> issuing_state :
> address :
> age :
> country :
> document_type :
> value : DRIVER LICENSE FRONT
> gender :
> image_id :
> image_signature :
> mrz :
> nationality :
> Thought: I now need to convert the information to text and then to
speech
> Action: edenai_text_to_speech
> Action Input: "Welcome Angela Greene!"
> Observation:
https://d14uq1pz7dzsdq.cloudfront.net/0c494819-0bbc-4433-bfa4-6e99bd9747ea_.mp3?Expires=1693316851&Signature=YcMoVQgPuIMEOuSpFuvhkFM8JoBMSoGMcZb7MVWdqw7JEf5~67q9dEI90o5todE5mYXB5zSYoib6rGrmfBl4Rn5~yqDwZ~Tmc24K75zpQZIEyt5~ZSnHuXy4IFWGmlIVuGYVGMGKxTGNeCRNUXDhT6TXGZlr4mwa79Ei1YT7KcNyc1dsTrYB96LphnsqOERx4X9J9XriSwxn70X8oUPFfQmLcitr-syDhiwd9Wdpg6J5yHAJjf657u7Z1lFTBMoXGBuw1VYmyno-3TAiPeUcVlQXPueJ-ymZXmwaITmGOfH7HipZngZBziofRAFdhMYbIjYhegu5jS7TxHwRuox32A__&Key-Pair-Id=K1F55BTI9AHGIK
> Thought: I now know the final answer
> Final Answer:
https://d14uq1pz7dzsdq.cloudfront.net/0c494819-0bbc-4433-bfa4-6e99bd9747ea_.mp3?Expires=1693316851&Signature=YcMoVQgPuIMEOuSpFuvhkFM8JoBMSoGMcZb7MVWdqw7JEf5~67q9dEI90o5todE5mYXB5zSYoib6rGrmfBl4Rn5~yqDwZ~Tmc24K75zpQZIEyt5~ZSnHuXy4IFWGmlIVuGYVGMGKxTGNeCRNUXDhT6TXGZlr4mwa79Ei1YT7KcNyc1dsTrYB96LphnsqOERx4X9J9XriSwxn70X8oUPFfQmLcitr-syDhiwd9Wdpg6J5y
>
> Finished chain.
Other examples are available in the jupyter notebook.
This PR is made in parallel with EdenAI LLM update #8963
I apologize for the messy PR. While working in implementing Tools we
realized there was a few problems we needed to fix on LLM as well.
Ping: @hwchase17, @baskaryan
---------
Co-authored-by: RedhaWassim <rwasssim@gmail.com>
2023-09-01 15:26:56 +00:00
|
|
|
"EdenAiExplicitImageTool",
|
|
|
|
"EdenAiObjectDetectionTool",
|
|
|
|
"EdenAiParsingIDTool",
|
|
|
|
"EdenAiParsingInvoiceTool",
|
|
|
|
"EdenAiSpeechToTextTool",
|
|
|
|
"EdenAiTextModerationTool",
|
|
|
|
"EdenAiTextToSpeechTool",
|
|
|
|
"EdenaiTool",
|
2023-08-31 14:02:24 +00:00
|
|
|
"ElevenLabsText2SpeechTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ExtractHyperlinksTool",
|
|
|
|
"ExtractTextTool",
|
|
|
|
"FileSearchTool",
|
|
|
|
"GetElementsTool",
|
2023-05-08 16:13:05 +00:00
|
|
|
"GmailCreateDraft",
|
|
|
|
"GmailGetMessage",
|
|
|
|
"GmailGetThread",
|
|
|
|
"GmailSearch",
|
|
|
|
"GmailSendMessage",
|
2023-10-30 21:05:39 +00:00
|
|
|
"GoogleCloudTextToSpeechTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"GooglePlacesTool",
|
|
|
|
"GoogleSearchResults",
|
|
|
|
"GoogleSearchRun",
|
2023-05-04 05:35:48 +00:00
|
|
|
"GoogleSerperResults",
|
|
|
|
"GoogleSerperRun",
|
2023-05-02 02:07:26 +00:00
|
|
|
"HumanInputRun",
|
|
|
|
"IFTTTWebhook",
|
2023-05-22 18:58:28 +00:00
|
|
|
"InfoPowerBITool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"InfoSQLDatabaseTool",
|
|
|
|
"InfoSparkSQLTool",
|
|
|
|
"JiraAction",
|
|
|
|
"JsonGetValueTool",
|
|
|
|
"JsonListKeysTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ListDirectoryTool",
|
2023-05-22 18:58:28 +00:00
|
|
|
"ListPowerBITool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"ListSQLDatabaseTool",
|
|
|
|
"ListSparkSQLTool",
|
Merriam-Webster Dictionary Tool (#12044)
# Description
We implemented a simple tool for accessing the Merriam-Webster
Collegiate Dictionary API
(https://dictionaryapi.com/products/api-collegiate-dictionary).
Here's a simple usage example:
```py
from langchain.llms import OpenAI
from langchain.agents import load_tools, initialize_agent, AgentType
llm = OpenAI()
tools = load_tools(["serpapi", "merriam-webster"], llm=llm) # Serp API gives our agent access to Google
agent = initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
agent.run("What is the english word for the german word Himbeere? Define that word.")
```
Sample output:
```
> Entering new AgentExecutor chain...
I need to find the english word for Himbeere and then get the definition of that word.
Action: Search
Action Input: "English word for Himbeere"
Observation: {'type': 'translation_result'}
Thought: Now I have the english word, I can look up the definition.
Action: MerriamWebster
Action Input: raspberry
Observation: Definitions of 'raspberry':
1. rasp-ber-ry, noun: any of various usually black or red edible berries that are aggregate fruits consisting of numerous small drupes on a fleshy receptacle and that are usually rounder and smaller than the closely related blackberries
2. rasp-ber-ry, noun: a perennial plant (genus Rubus) of the rose family that bears raspberries
3. rasp-ber-ry, noun: a sound of contempt made by protruding the tongue between the lips and expelling air forcibly to produce a vibration; broadly : an expression of disapproval or contempt
4. black raspberry, noun: a raspberry (Rubus occidentalis) of eastern North America that has a purplish-black fruit and is the source of several cultivated varieties —called also blackcap
Thought: I now know the final answer.
Final Answer: Raspberry is an english word for Himbeere and it is defined as any of various usually black or red edible berries that are aggregate fruits consisting of numerous small drupes on a fleshy receptacle and that are usually rounder and smaller than the closely related blackberries.
> Finished chain.
```
# Issue
This closes #12039.
# Dependencies
We added no extra dependencies.
<!-- Thank you for contributing to LangChain!
Replace this entire comment with:
- **Description:** a description of the change,
- **Issue:** the issue # it fixes (if applicable),
- **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!
Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.
See contribution guidelines for more information on how to write/run
tests, lint, etc:
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md
If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.
If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
-->
---------
Co-authored-by: Lara <63805048+larkgz@users.noreply.github.com>
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2023-11-30 01:28:29 +00:00
|
|
|
"MerriamWebsterQueryRun",
|
2023-05-14 04:45:05 +00:00
|
|
|
"MetaphorSearchResults",
|
2023-05-02 02:07:26 +00:00
|
|
|
"MoveFileTool",
|
2023-12-04 21:43:11 +00:00
|
|
|
"NasaAction",
|
2023-05-02 02:07:26 +00:00
|
|
|
"NavigateBackTool",
|
|
|
|
"NavigateTool",
|
2023-10-31 21:58:09 +00:00
|
|
|
"O365CreateDraftMessage",
|
2023-07-05 19:46:21 +00:00
|
|
|
"O365SearchEmails",
|
|
|
|
"O365SearchEvents",
|
|
|
|
"O365SendEvent",
|
2023-10-31 21:58:09 +00:00
|
|
|
"O365SendMessage",
|
2023-05-02 02:07:26 +00:00
|
|
|
"OpenAPISpec",
|
2023-05-15 01:50:45 +00:00
|
|
|
"OpenWeatherMapQueryRun",
|
2023-06-18 23:55:18 +00:00
|
|
|
"PubmedQueryRun",
|
2024-01-21 23:08:55 +00:00
|
|
|
"PolygonLastQuote",
|
Add multi-input Reddit search tool (#13893)
- **Description:** Added a tool called RedditSearchRun and an
accompanying API wrapper, which searches Reddit for posts with support
for time filtering, post sorting, query string and subreddit filtering.
- **Issue:** #13891
- **Dependencies:** `praw` module is used to search Reddit
- **Tag maintainer:** @baskaryan , and any of the other maintainers if
needed
- **Twitter handle:** None.
Hello,
This is our first PR and we hope that our changes will be helpful to the
community. We have run `make format`, `make lint` and `make test`
locally before submitting the PR. To our knowledge, our changes do not
introduce any new errors.
Our PR integrates the `praw` package which is already used by
RedditPostsLoader in LangChain. Nonetheless, we have added integration
tests and edited unit tests to test our changes. An example notebook is
also provided. These changes were put together by me, @Anika2000,
@CharlesXu123, and @Jeremy-Cheng-stack
Thank you in advance to the maintainers for their time.
---------
Co-authored-by: What-Is-A-Username <49571870+What-Is-A-Username@users.noreply.github.com>
Co-authored-by: Anika2000 <anika.sultana@mail.utoronto.ca>
Co-authored-by: Jeremy Cheng <81793294+Jeremy-Cheng-stack@users.noreply.github.com>
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2023-11-30 01:16:40 +00:00
|
|
|
"RedditSearchRun",
|
2023-06-18 23:55:18 +00:00
|
|
|
"QueryCheckerTool",
|
2023-05-22 18:58:28 +00:00
|
|
|
"QueryPowerBITool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"QuerySQLCheckerTool",
|
|
|
|
"QuerySQLDataBaseTool",
|
|
|
|
"QuerySparkSQLTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ReadFileTool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"RequestsDeleteTool",
|
|
|
|
"RequestsGetTool",
|
|
|
|
"RequestsPatchTool",
|
|
|
|
"RequestsPostTool",
|
|
|
|
"RequestsPutTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"SceneXplainTool",
|
2023-12-05 00:34:15 +00:00
|
|
|
"SearchAPIResults",
|
|
|
|
"SearchAPIRun",
|
2023-06-18 23:55:18 +00:00
|
|
|
"SearxSearchResults",
|
|
|
|
"SearxSearchRun",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ShellTool",
|
2023-12-03 18:25:38 +00:00
|
|
|
"SlackGetChannel",
|
|
|
|
"SlackGetMessage",
|
|
|
|
"SlackScheduleMessage",
|
|
|
|
"SlackSendMessage",
|
2023-06-18 23:55:18 +00:00
|
|
|
"SleepTool",
|
|
|
|
"StdInInquireTool",
|
2023-11-29 18:32:07 +00:00
|
|
|
"StackExchangeTool",
|
2023-05-12 17:35:01 +00:00
|
|
|
"SteamshipImageGenerationTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"StructuredTool",
|
2023-12-04 20:27:38 +00:00
|
|
|
"SteamWebAPIQueryRun",
|
2023-05-02 02:07:26 +00:00
|
|
|
"Tool",
|
|
|
|
"VectorStoreQATool",
|
|
|
|
"VectorStoreQAWithSourcesTool",
|
|
|
|
"WikipediaQueryRun",
|
|
|
|
"WolframAlphaQueryRun",
|
|
|
|
"WriteFileTool",
|
2023-10-31 21:58:09 +00:00
|
|
|
"YahooFinanceNewsTool",
|
2023-06-18 23:55:18 +00:00
|
|
|
"YouTubeSearchTool",
|
2023-05-02 02:07:26 +00:00
|
|
|
"ZapierNLAListActions",
|
|
|
|
"ZapierNLARunAction",
|
2023-10-31 21:58:09 +00:00
|
|
|
"authenticate",
|
2023-06-13 17:40:49 +00:00
|
|
|
"format_tool_to_openai_function",
|
2023-06-18 23:55:18 +00:00
|
|
|
"tool",
|
2023-05-02 02:07:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def test_public_api() -> None:
|
|
|
|
"""Test for regressions or changes in the public API."""
|
|
|
|
# Check that the public API is as expected
|
2023-08-01 16:12:32 +00:00
|
|
|
assert set(public_api) == set(_EXPECTED)
|