Jelajahi Sumber

fix: file in _instructions directory not set correctly. (#1602)

Co-authored-by: aaren.xzh <aaren.xzh@antfin.com>
Xia Zhenhua 1 tahun lalu
induk
melakukan
2d24521222
1 mengubah file dengan 10 tambahan dan 7 penghapusan
  1. 10 7
      agenthub/micro/instructions.py

+ 10 - 7
agenthub/micro/instructions.py

@@ -7,13 +7,16 @@ base_dir = os.path.dirname(os.path.abspath(__file__)) + '/_instructions'
 for root, dirs, files in os.walk(base_dir):
     if len(files) == 0:
         continue
-    rel_base = os.path.relpath(root, base_dir)
-    keys = rel_base.split('/')
-    obj = instructions
-    for key in keys:
-        if key not in obj:
-            obj[key] = {}
-        obj = obj[key]
+    if root == base_dir:
+        obj = instructions
+    else:
+        rel_base = os.path.relpath(root, base_dir)
+        keys = rel_base.split('/')
+        obj = instructions
+        for key in keys:
+            if key not in obj:
+                obj[key] = {}
+            obj = obj[key]
     for file in files:
         without_ext = os.path.splitext(file)[0]
         with open(os.path.join(root, file), 'r') as f: