From f03a5dd59c2e0c85b20775e9232db33ad2ba5034 Mon Sep 17 00:00:00 2001 From: yzlin Date: Tue, 20 Feb 2024 22:56:50 +0800 Subject: [PATCH] fix tool path bug --- metagpt/tools/tool_registry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/tools/tool_registry.py b/metagpt/tools/tool_registry.py index 5fbd39421..02eecb0f3 100644 --- a/metagpt/tools/tool_registry.py +++ b/metagpt/tools/tool_registry.py @@ -9,7 +9,6 @@ from __future__ import annotations import inspect import os -import re from collections import defaultdict import yaml @@ -109,7 +108,8 @@ def register_tool(tool_type: str = "other", schema_path: str = "", **kwargs): # Get the file path where the function / class is defined and the source code file_path = inspect.getfile(cls) if "metagpt" in file_path: - file_path = re.search("metagpt.+", file_path).group(0) + # split to handle ../metagpt/metagpt/tools/... where only metapgt/tools/... is needed + file_path = "metagpt" + file_path.split("metagpt")[-1] source_code = inspect.getsource(cls) TOOL_REGISTRY.register_tool(