Skip to content

[Bug] 函数工具重复创建 #3218

@Flartiny

Description

@Flartiny

发生了什么

以类的形式加函数工具,重载插件不会卸载函数工具导致重复创建。
也许AstrBot本体可以修复,或者在文档中提及由插件本身处理。

如何复现?

按文档

class MyPlugin(Star):
    def __init__(self, context: Context):
        super().__init__(context)
        # >= v4.5.1 使用:
        self.context.add_llm_tools(HelloWorldTool(), SecondTool(), ...)

部分原因是add_llm_tools直接append导致所述问题

def add_llm_tools(self, *tools: FunctionTool) -> None:
        """添加 LLM 工具。"""
        for tool in tools:
            self.provider_manager.llm_tools.func_list.append(tool)

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot v4.5.0

操作系统

Linux

报错日志

Image

你愿意提交 PR 吗?

  • 是的,我愿意提交 PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions