Skip to content

Commit f03a5dd

Browse files
committed
fix tool path bug
1 parent 56435cd commit f03a5dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

metagpt/tools/tool_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import inspect
1111
import os
12-
import re
1312
from collections import defaultdict
1413

1514
import yaml
@@ -109,7 +108,8 @@ def decorator(cls):
109108
# Get the file path where the function / class is defined and the source code
110109
file_path = inspect.getfile(cls)
111110
if "metagpt" in file_path:
112-
file_path = re.search("metagpt.+", file_path).group(0)
111+
# split to handle ../metagpt/metagpt/tools/... where only metapgt/tools/... is needed
112+
file_path = "metagpt" + file_path.split("metagpt")[-1]
113113
source_code = inspect.getsource(cls)
114114

115115
TOOL_REGISTRY.register_tool(

0 commit comments

Comments
 (0)