mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-18 19:44:21 +00:00
feat: tool loader abstraction
This commit is contained in:
@@ -3,11 +3,11 @@ from __future__ import annotations
|
||||
import abc
|
||||
import typing
|
||||
|
||||
from ...core import app
|
||||
from ...core import app, entities as core_entities
|
||||
from . import entities as tools_entities
|
||||
|
||||
|
||||
preregistered_loaders = []
|
||||
preregistered_loaders: list[typing.Type[ToolLoader]] = []
|
||||
|
||||
def loader_class(name: str):
|
||||
"""注册一个工具加载器
|
||||
@@ -34,6 +34,16 @@ class ToolLoader(abc.ABC):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_tools(self) -> list[tools_entities.LLMFunction]:
|
||||
async def get_tools(self, enabled: bool=True) -> list[tools_entities.LLMFunction]:
|
||||
"""获取所有工具"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def has_tool(self, name: str) -> bool:
|
||||
"""检查工具是否存在"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def invoke_tool(self, query: core_entities.Query, name: str, parameters: dict) -> typing.Any:
|
||||
"""执行工具调用"""
|
||||
pass
|
||||
Reference in New Issue
Block a user