Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_file function implemented in tools #14301

Merged
merged 6 commits into from
Mar 30, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/langchain/langchain/agents/load_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import Any, Dict, List, Optional, Callable, Tuple
from mypy_extensions import Arg, KwArg

from langchain_community.tools.file_management import ReadFileTool
from langchain_core.tools import Tool
from langchain_core.language_models import BaseLanguageModel
from langchain_core.callbacks import BaseCallbackManager
Expand Down Expand Up @@ -105,6 +106,7 @@
from langchain_community.utilities.reddit_search import RedditSearchAPIWrapper



def _get_tools_requests_get() -> BaseTool:
# Dangerous requests are allowed here, because there's another flag that the user
# has to provide in order to actually opt in.
Expand Down Expand Up @@ -412,6 +414,9 @@ def _get_memorize(llm: BaseLanguageModel, **kwargs: Any) -> BaseTool:
def _get_google_cloud_texttospeech(**kwargs: Any) -> BaseTool:
return GoogleCloudTextToSpeechTool(**kwargs)

def _get_file_management_tool(**kwargs: Any) -> BaseTool:
return ReadFileTool(**kwargs)


def _get_reddit_search(**kwargs: Any) -> BaseTool:
return RedditSearchRun(api_wrapper=RedditSearchAPIWrapper(**kwargs))
Expand Down Expand Up @@ -501,6 +506,7 @@ def _get_reddit_search(**kwargs: Any) -> BaseTool:
),
"eleven_labs_text2speech": (_get_eleven_labs_text2speech, ["eleven_api_key"]),
"google_cloud_texttospeech": (_get_google_cloud_texttospeech, []),
"read_file": (_get_file_managent_tool, []),
"reddit_search": (
_get_reddit_search,
["reddit_client_id", "reddit_client_secret", "reddit_user_agent"],
Expand Down
Loading