Skip to content

Commit c7b197f

Browse files
authored
Merge pull request #912 from garylin2099/v0.7-release
fix tool path bug
2 parents 0ea991f + f03a5dd commit c7b197f

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)