feat: switch tool entities and format

This commit is contained in:
Junyan Qin
2025-06-15 12:51:51 +08:00
parent c5eeab2fd0
commit 0c2560cafb
55 changed files with 455 additions and 774 deletions
+5 -4
View File
@@ -3,9 +3,10 @@ from __future__ import annotations
import typing
import traceback
from .. import loader, entities as tools_entities
from .. import loader
from ....core import entities as core_entities
from ....plugin import context as plugin_context
import langbot_plugin.api.entities.builtin.resource.tool as resource_tool
@loader.loader_class('plugin-tool-loader')
@@ -15,9 +16,9 @@ class PluginToolLoader(loader.ToolLoader):
本加载器中不存储工具信息,仅负责从插件系统中获取工具信息。
"""
async def get_tools(self, enabled: bool = True) -> list[tools_entities.LLMFunction]:
async def get_tools(self, enabled: bool = True) -> list[resource_tool.LLMTool]:
# 从插件系统获取工具(内容函数)
all_functions: list[tools_entities.LLMFunction] = []
all_functions: list[resource_tool.LLMTool] = []
for plugin in self.ap.plugin_mgr.plugins(
enabled=enabled, status=plugin_context.RuntimeContainerStatus.INITIALIZED
@@ -38,7 +39,7 @@ class PluginToolLoader(loader.ToolLoader):
async def _get_function_and_plugin(
self, name: str
) -> typing.Tuple[tools_entities.LLMFunction, plugin_context.BasePlugin]:
) -> typing.Tuple[resource_tool.LLMTool, plugin_context.BasePlugin]:
"""获取函数和插件实例"""
for plugin in self.ap.plugin_mgr.plugins(
enabled=True, status=plugin_context.RuntimeContainerStatus.INITIALIZED