From 98863ab90160822546c4e6f65b6030a6081d2160 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 8 Sep 2024 08:16:36 -0400 Subject: [PATCH] feat: customized tool-use --- astrbot/message/handler.py | 4 +++- util/agent/func_call.py | 1 - util/agent/web_searcher.py | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/astrbot/message/handler.py b/astrbot/message/handler.py index 89383a46..a2072643 100644 --- a/astrbot/message/handler.py +++ b/astrbot/message/handler.py @@ -214,7 +214,9 @@ class MessageHandler(): return MessageResult("AstrBot Function-calling 异常:未找到请求的函数调用。") try: args = json.loads(llm_result.arguments) - function_invoked_ret = await func_obj(**args) + args['ame'] = message + args['context'] = self.context + llm_result = await func_obj(**args) has_func = True except BaseException as e: traceback.print_exc() diff --git a/util/agent/func_call.py b/util/agent/func_call.py index 5283ee4d..830496ca 100644 --- a/util/agent/func_call.py +++ b/util/agent/func_call.py @@ -1,6 +1,5 @@ from model.provider.provider import Provider import json -import time import textwrap class FuncCallJsonFormatError(Exception): diff --git a/util/agent/web_searcher.py b/util/agent/web_searcher.py index e519ca69..d9b38431 100644 --- a/util/agent/web_searcher.py +++ b/util/agent/web_searcher.py @@ -1,6 +1,4 @@ -import traceback import random -import json import aiohttp import os