From 52b8ba84d32d6d42b6dde75b772d2dd68195c9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=A3=92=E6=A3=92?= Date: Tue, 19 Dec 2023 17:57:16 +0800 Subject: [PATCH] update globals with function tools. --- metagpt/tools/functions/libs/udf/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metagpt/tools/functions/libs/udf/__init__.py b/metagpt/tools/functions/libs/udf/__init__.py index b74ae2ab9..5d9c35b27 100644 --- a/metagpt/tools/functions/libs/udf/__init__.py +++ b/metagpt/tools/functions/libs/udf/__init__.py @@ -29,6 +29,8 @@ def extract_function_signatures(file_path): # 导入函数 module_name = Path(file_path).parts[-1][:-len(Path(file_path).suffix)] module = importlib.import_module(f"metagpt.tools.functions.libs.udf.{module_name}") + # 将函数导入到当前命名空间 + globals().update({function_name: getattr(module, function_name)}) # 获取函数注释和函数路径 function_schema = {'udf_name': function_signature, 'udf_path': f'from metagpt.tools.functions.libs.udf.{module_name} import {function_name}',