mirror of
https://github.com/corca-ai/EVAL
synced 2024-11-01 03:20:10 +00:00
21 lines
561 B
Python
21 lines
561 B
Python
|
from typing import Optional
|
||
|
|
||
|
from langchain.llms.base import BaseLLM
|
||
|
from langchain.agents import load_tools
|
||
|
from langchain.agents.tools import BaseTool
|
||
|
|
||
|
from .base import BaseToolSet
|
||
|
|
||
|
|
||
|
class ToolsFactory:
|
||
|
@staticmethod
|
||
|
def from_toolsets(toolsets: list[BaseToolSet]) -> list[BaseTool]:
|
||
|
tools = []
|
||
|
for toolset in toolsets:
|
||
|
tools.extend(toolset.to_tools())
|
||
|
return tools
|
||
|
|
||
|
@staticmethod
|
||
|
def from_names(toolnames: list[str], llm: Optional[BaseLLM]) -> list[BaseTool]:
|
||
|
return load_tools(toolnames, llm=llm)
|