From 38adbfdf3406a161e3be189b7e4f3b1f6eb0f00b Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Mon, 22 Apr 2024 14:04:30 -0400 Subject: [PATCH] community[patch],core[minor]: Move BaseToolKit to core.tools (#20669) --- .../langchain_community/agent_toolkits/base.py | 15 ++------------- libs/core/langchain_core/tools.py | 10 +++++++++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libs/community/langchain_community/agent_toolkits/base.py b/libs/community/langchain_community/agent_toolkits/base.py index 0315184115e4c..0776de523b5c1 100644 --- a/libs/community/langchain_community/agent_toolkits/base.py +++ b/libs/community/langchain_community/agent_toolkits/base.py @@ -1,15 +1,4 @@ """Toolkits for agents.""" -from abc import ABC, abstractmethod -from typing import List +from langchain_core.tools import BaseToolkit -from langchain_core.pydantic_v1 import BaseModel - -from langchain_community.tools import BaseTool - - -class BaseToolkit(BaseModel, ABC): - """Base Toolkit representing a collection of related tools.""" - - @abstractmethod - def get_tools(self) -> List[BaseTool]: - """Get the tools in the toolkit.""" +__all__ = ["BaseToolkit"] diff --git a/libs/core/langchain_core/tools.py b/libs/core/langchain_core/tools.py index d7abd121cbbea..363d12b950f1a 100644 --- a/libs/core/langchain_core/tools.py +++ b/libs/core/langchain_core/tools.py @@ -22,7 +22,7 @@ import inspect import uuid import warnings -from abc import abstractmethod +from abc import ABC, abstractmethod from functools import partial from inspect import signature from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union @@ -1038,3 +1038,11 @@ def render_text_description_and_args(tools: List[BaseTool]) -> str: args_schema = str(tool.args) tool_strings.append(f"{tool.name}: {tool.description}, args: {args_schema}") return "\n".join(tool_strings) + + +class BaseToolkit(BaseModel, ABC): + """Base Toolkit representing a collection of related tools.""" + + @abstractmethod + def get_tools(self) -> List[BaseTool]: + """Get the tools in the toolkit."""