jarvis-ai-assistant 0.1.96__py3-none-any.whl → 0.1.97__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/agent.py +138 -144
- jarvis/jarvis_codebase/main.py +87 -54
- jarvis/jarvis_coder/git_utils.py +4 -7
- jarvis/jarvis_coder/main.py +17 -22
- jarvis/jarvis_coder/patch_handler.py +141 -441
- jarvis/jarvis_coder/plan_generator.py +64 -36
- jarvis/jarvis_platform/main.py +1 -1
- jarvis/jarvis_rag/main.py +1 -1
- jarvis/jarvis_smart_shell/main.py +15 -15
- jarvis/main.py +24 -24
- jarvis/models/ai8.py +22 -22
- jarvis/models/base.py +17 -13
- jarvis/models/kimi.py +31 -31
- jarvis/models/ollama.py +28 -28
- jarvis/models/openai.py +22 -24
- jarvis/models/oyi.py +25 -25
- jarvis/models/registry.py +33 -34
- jarvis/tools/ask_user.py +5 -5
- jarvis/tools/base.py +2 -2
- jarvis/tools/chdir.py +9 -9
- jarvis/tools/codebase_qa.py +4 -4
- jarvis/tools/coder.py +4 -4
- jarvis/tools/file_ops.py +1 -1
- jarvis/tools/generator.py +23 -23
- jarvis/tools/methodology.py +4 -4
- jarvis/tools/rag.py +4 -4
- jarvis/tools/registry.py +38 -38
- jarvis/tools/search.py +42 -42
- jarvis/tools/shell.py +13 -13
- jarvis/tools/sub_agent.py +16 -16
- jarvis/tools/thinker.py +41 -41
- jarvis/tools/webpage.py +17 -17
- jarvis/utils.py +59 -60
- {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.97.dist-info}/METADATA +1 -1
- jarvis_ai_assistant-0.1.97.dist-info/RECORD +47 -0
- jarvis_ai_assistant-0.1.96.dist-info/RECORD +0 -47
- {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.97.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.97.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.97.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.96.dist-info → jarvis_ai_assistant-0.1.97.dist-info}/top_level.txt +0 -0
jarvis/models/registry.py
CHANGED
|
@@ -19,7 +19,7 @@ REQUIRED_METHODS = [
|
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
class PlatformRegistry:
|
|
22
|
-
"""
|
|
22
|
+
"""Platform registry"""
|
|
23
23
|
|
|
24
24
|
global_platform_name = "kimi"
|
|
25
25
|
global_platform_registry = None
|
|
@@ -37,19 +37,19 @@ class PlatformRegistry:
|
|
|
37
37
|
|
|
38
38
|
pass
|
|
39
39
|
except Exception as e:
|
|
40
|
-
PrettyOutput.print(f"
|
|
40
|
+
PrettyOutput.print(f"Create platform directory failed: {str(e)}", OutputType.ERROR)
|
|
41
41
|
return ""
|
|
42
42
|
return user_platform_dir
|
|
43
43
|
|
|
44
44
|
@staticmethod
|
|
45
45
|
def check_platform_implementation(platform_class: Type[BasePlatform]) -> bool:
|
|
46
|
-
"""
|
|
46
|
+
"""Check if the platform class implements all necessary methods
|
|
47
47
|
|
|
48
48
|
Args:
|
|
49
|
-
platform_class:
|
|
49
|
+
platform_class: The platform class to check
|
|
50
50
|
|
|
51
51
|
Returns:
|
|
52
|
-
bool:
|
|
52
|
+
bool: Whether all necessary methods are implemented
|
|
53
53
|
"""
|
|
54
54
|
missing_methods = []
|
|
55
55
|
|
|
@@ -68,11 +68,11 @@ class PlatformRegistry:
|
|
|
68
68
|
sig = inspect.signature(method)
|
|
69
69
|
method_params = [p for p in sig.parameters if p != 'self']
|
|
70
70
|
if len(method_params) != len(params):
|
|
71
|
-
missing_methods.append(f"{method_name}(
|
|
71
|
+
missing_methods.append(f"{method_name}(parameter mismatch)")
|
|
72
72
|
|
|
73
73
|
if missing_methods:
|
|
74
74
|
PrettyOutput.print(
|
|
75
|
-
f"
|
|
75
|
+
f"Platform {platform_class.__name__} is missing necessary methods: {', '.join(missing_methods)}",
|
|
76
76
|
OutputType.ERROR
|
|
77
77
|
)
|
|
78
78
|
return False
|
|
@@ -81,19 +81,19 @@ class PlatformRegistry:
|
|
|
81
81
|
|
|
82
82
|
@staticmethod
|
|
83
83
|
def load_platform_from_dir(directory: str) -> Dict[str, Type[BasePlatform]]:
|
|
84
|
-
"""
|
|
84
|
+
"""Load platforms from specified directory
|
|
85
85
|
|
|
86
86
|
Args:
|
|
87
|
-
directory:
|
|
87
|
+
directory: Platform directory path
|
|
88
88
|
|
|
89
89
|
Returns:
|
|
90
|
-
Dict[str, Type[BasePlatform]]:
|
|
90
|
+
Dict[str, Type[BasePlatform]]: Platform name to platform class mapping
|
|
91
91
|
"""
|
|
92
92
|
platforms = {}
|
|
93
93
|
|
|
94
94
|
# 确保目录存在
|
|
95
95
|
if not os.path.exists(directory):
|
|
96
|
-
PrettyOutput.print(f"
|
|
96
|
+
PrettyOutput.print(f"Platform directory does not exist: {directory}", OutputType.ERROR)
|
|
97
97
|
return platforms
|
|
98
98
|
|
|
99
99
|
# 获取目录的包名
|
|
@@ -127,18 +127,18 @@ class PlatformRegistry:
|
|
|
127
127
|
if not PlatformRegistry.check_platform_implementation(obj):
|
|
128
128
|
continue
|
|
129
129
|
if not PlatformRegistry.suppress_output:
|
|
130
|
-
PrettyOutput.print(f"
|
|
131
|
-
platforms[obj.platform_name] = obj
|
|
130
|
+
PrettyOutput.print(f"Load platform from {os.path.join(directory, filename)}: {obj.platform_name}", OutputType.SUCCESS) # type: ignore
|
|
131
|
+
platforms[obj.platform_name] = obj # type: ignore
|
|
132
132
|
break
|
|
133
133
|
except Exception as e:
|
|
134
|
-
PrettyOutput.print(f"
|
|
134
|
+
PrettyOutput.print(f"Load platform {module_name} failed: {str(e)}", OutputType.ERROR)
|
|
135
135
|
|
|
136
136
|
return platforms
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
@staticmethod
|
|
140
140
|
def get_global_platform_registry():
|
|
141
|
-
"""
|
|
141
|
+
"""Get global platform registry"""
|
|
142
142
|
if PlatformRegistry.global_platform_registry is None:
|
|
143
143
|
PlatformRegistry.global_platform_registry = PlatformRegistry()
|
|
144
144
|
|
|
@@ -154,58 +154,57 @@ class PlatformRegistry:
|
|
|
154
154
|
return PlatformRegistry.global_platform_registry
|
|
155
155
|
|
|
156
156
|
def __init__(self):
|
|
157
|
-
"""
|
|
158
|
-
"""
|
|
157
|
+
"""Initialize platform registry"""
|
|
159
158
|
self.platforms: Dict[str, Type[BasePlatform]] = {}
|
|
160
159
|
|
|
161
160
|
def get_normal_platform(self) -> BasePlatform:
|
|
162
161
|
platform_name = os.environ.get("JARVIS_PLATFORM", "kimi")
|
|
163
162
|
model_name = os.environ.get("JARVIS_MODEL", "kimi")
|
|
164
163
|
platform = self.create_platform(platform_name)
|
|
165
|
-
platform.set_model_name(model_name)
|
|
166
|
-
return platform
|
|
164
|
+
platform.set_model_name(model_name) # type: ignore
|
|
165
|
+
return platform # type: ignore
|
|
167
166
|
|
|
168
167
|
def get_codegen_platform(self) -> BasePlatform:
|
|
169
168
|
platform_name = os.environ.get("JARVIS_CODEGEN_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
|
|
170
169
|
model_name = os.environ.get("JARVIS_CODEGEN_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
|
|
171
170
|
platform = self.create_platform(platform_name)
|
|
172
|
-
platform.set_model_name(model_name)
|
|
173
|
-
return platform
|
|
171
|
+
platform.set_model_name(model_name) # type: ignore
|
|
172
|
+
return platform # type: ignore
|
|
174
173
|
|
|
175
174
|
def get_cheap_platform(self) -> BasePlatform:
|
|
176
175
|
platform_name = os.environ.get("JARVIS_CHEAP_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
|
|
177
176
|
model_name = os.environ.get("JARVIS_CHEAP_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
|
|
178
177
|
platform = self.create_platform(platform_name)
|
|
179
|
-
platform.set_model_name(model_name)
|
|
180
|
-
return platform
|
|
178
|
+
platform.set_model_name(model_name) # type: ignore
|
|
179
|
+
return platform # type: ignore
|
|
181
180
|
|
|
182
181
|
def get_thinking_platform(self) -> BasePlatform:
|
|
183
182
|
platform_name = os.environ.get("JARVIS_THINKING_PLATFORM", os.environ.get("JARVIS_PLATFORM", "kimi"))
|
|
184
183
|
model_name = os.environ.get("JARVIS_THINKING_MODEL", os.environ.get("JARVIS_MODEL", "kimi"))
|
|
185
184
|
platform = self.create_platform(platform_name)
|
|
186
|
-
platform.set_model_name(model_name)
|
|
187
|
-
return platform
|
|
185
|
+
platform.set_model_name(model_name) # type: ignore
|
|
186
|
+
return platform # type: ignore
|
|
188
187
|
|
|
189
188
|
def register_platform(self, name: str, platform_class: Type[BasePlatform]):
|
|
190
|
-
"""
|
|
189
|
+
"""Register platform class
|
|
191
190
|
|
|
192
191
|
Args:
|
|
193
|
-
name:
|
|
194
|
-
model_class:
|
|
192
|
+
name: Platform name
|
|
193
|
+
model_class: Platform class
|
|
195
194
|
"""
|
|
196
195
|
self.platforms[name] = platform_class
|
|
197
196
|
|
|
198
197
|
def create_platform(self, name: str) -> Optional[BasePlatform]:
|
|
199
|
-
"""
|
|
198
|
+
"""Create platform instance
|
|
200
199
|
|
|
201
200
|
Args:
|
|
202
|
-
name:
|
|
201
|
+
name: Platform name
|
|
203
202
|
|
|
204
203
|
Returns:
|
|
205
|
-
BasePlatform:
|
|
204
|
+
BasePlatform: Platform instance
|
|
206
205
|
"""
|
|
207
206
|
if name not in self.platforms:
|
|
208
|
-
PrettyOutput.print(f"
|
|
207
|
+
PrettyOutput.print(f"Platform not found: {name}", OutputType.ERROR)
|
|
209
208
|
return None
|
|
210
209
|
|
|
211
210
|
try:
|
|
@@ -213,10 +212,10 @@ class PlatformRegistry:
|
|
|
213
212
|
platform = self.platforms[name]()
|
|
214
213
|
return platform
|
|
215
214
|
except Exception as e:
|
|
216
|
-
PrettyOutput.print(f"
|
|
215
|
+
PrettyOutput.print(f"Create platform failed: {str(e)}", OutputType.ERROR)
|
|
217
216
|
return None
|
|
218
217
|
|
|
219
218
|
def get_available_platforms(self) -> List[str]:
|
|
220
|
-
"""
|
|
219
|
+
"""Get available platform list"""
|
|
221
220
|
return list(self.platforms.keys())
|
|
222
221
|
|
jarvis/tools/ask_user.py
CHANGED
|
@@ -4,13 +4,13 @@ from jarvis.utils import get_multiline_input, PrettyOutput, OutputType
|
|
|
4
4
|
|
|
5
5
|
class AskUserTool:
|
|
6
6
|
name="ask_user"
|
|
7
|
-
description="""
|
|
7
|
+
description="""Ask the user when information needed to complete the task is missing or when critical decision information is lacking. Users can input multiple lines of text, ending with an empty line. Use cases: 1. Need user to provide more information to complete the task; 2. Need user to make critical decisions; 3. Need user to confirm important operations; 4. Need user to provide additional information"""
|
|
8
8
|
parameters={
|
|
9
9
|
"type": "object",
|
|
10
10
|
"properties": {
|
|
11
11
|
"question": {
|
|
12
12
|
"type": "string",
|
|
13
|
-
"description": "
|
|
13
|
+
"description": "The question to ask the user"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"required": ["question"]
|
|
@@ -34,12 +34,12 @@ class AskUserTool:
|
|
|
34
34
|
PrettyOutput.print(question, OutputType.SYSTEM)
|
|
35
35
|
|
|
36
36
|
# 获取用户输入
|
|
37
|
-
user_response = get_multiline_input("
|
|
37
|
+
user_response = get_multiline_input("Please enter your answer (input empty line to end)")
|
|
38
38
|
|
|
39
39
|
if user_response == "__interrupt__":
|
|
40
40
|
return {
|
|
41
41
|
"success": False,
|
|
42
|
-
"error": "
|
|
42
|
+
"error": "User canceled input"
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return {
|
|
@@ -50,5 +50,5 @@ class AskUserTool:
|
|
|
50
50
|
except Exception as e:
|
|
51
51
|
return {
|
|
52
52
|
"success": False,
|
|
53
|
-
"error": f"
|
|
53
|
+
"error": f"Failed to ask user: {str(e)}"
|
|
54
54
|
}
|
jarvis/tools/base.py
CHANGED
|
@@ -11,7 +11,7 @@ class Tool:
|
|
|
11
11
|
self.func = func
|
|
12
12
|
|
|
13
13
|
def to_dict(self) -> Dict:
|
|
14
|
-
"""
|
|
14
|
+
"""Convert to tool format"""
|
|
15
15
|
return {
|
|
16
16
|
"name": self.name,
|
|
17
17
|
"description": self.description,
|
|
@@ -19,5 +19,5 @@ class Tool:
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
def execute(self, arguments: Dict) -> Dict[str, Any]:
|
|
22
|
-
"""
|
|
22
|
+
"""Execute tool function"""
|
|
23
23
|
return self.func(arguments)
|
jarvis/tools/chdir.py
CHANGED
|
@@ -6,13 +6,13 @@ class ChdirTool:
|
|
|
6
6
|
"""修改当前工作目录的工具"""
|
|
7
7
|
|
|
8
8
|
name = "chdir"
|
|
9
|
-
description = "
|
|
9
|
+
description = "Change current working directory"
|
|
10
10
|
parameters = {
|
|
11
11
|
"type": "object",
|
|
12
12
|
"properties": {
|
|
13
13
|
"path": {
|
|
14
14
|
"type": "string",
|
|
15
|
-
"description": "
|
|
15
|
+
"description": "Directory path to switch to, supports both relative and absolute paths"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"required": ["path"]
|
|
@@ -38,14 +38,14 @@ class ChdirTool:
|
|
|
38
38
|
if not os.path.exists(path):
|
|
39
39
|
return {
|
|
40
40
|
"success": False,
|
|
41
|
-
"error": f"
|
|
41
|
+
"error": f"Directory does not exist: {path}"
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
# 检查是否是目录
|
|
45
45
|
if not os.path.isdir(path):
|
|
46
46
|
return {
|
|
47
47
|
"success": False,
|
|
48
|
-
"error": f"
|
|
48
|
+
"error": f"The path is not a directory: {path}"
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
# 尝试切换目录
|
|
@@ -54,27 +54,27 @@ class ChdirTool:
|
|
|
54
54
|
|
|
55
55
|
return {
|
|
56
56
|
"success": True,
|
|
57
|
-
"stdout": f"
|
|
57
|
+
"stdout": f"Changed working directory:\nFrom: {old_path}\nTo: {path}",
|
|
58
58
|
"stderr": ""
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
except PermissionError:
|
|
62
62
|
return {
|
|
63
63
|
"success": False,
|
|
64
|
-
"error": f"
|
|
64
|
+
"error": f"No permission to access directory: {path}"
|
|
65
65
|
}
|
|
66
66
|
except Exception as e:
|
|
67
67
|
return {
|
|
68
68
|
"success": False,
|
|
69
|
-
"error": f"
|
|
69
|
+
"error": f"Failed to switch directory: {str(e)}"
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
def main():
|
|
73
73
|
"""命令行直接运行工具"""
|
|
74
74
|
import argparse
|
|
75
75
|
|
|
76
|
-
parser = argparse.ArgumentParser(description='
|
|
77
|
-
parser.add_argument('path', help='
|
|
76
|
+
parser = argparse.ArgumentParser(description='Change current working directory')
|
|
77
|
+
parser.add_argument('path', help='Directory path to switch to, supports both relative and absolute paths')
|
|
78
78
|
args = parser.parse_args()
|
|
79
79
|
|
|
80
80
|
tool = ChdirTool()
|
jarvis/tools/codebase_qa.py
CHANGED
|
@@ -7,21 +7,21 @@ class CodebaseQATool:
|
|
|
7
7
|
"""代码库问答工具,用于回答关于代码库的问题"""
|
|
8
8
|
|
|
9
9
|
name = "codebase_qa"
|
|
10
|
-
description = "
|
|
10
|
+
description = "Answer questions about the codebase, can query and understand code functionality, structure, and implementation details"
|
|
11
11
|
parameters = {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"properties": {
|
|
14
14
|
"dir": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"description": "
|
|
16
|
+
"description": "Project root directory"
|
|
17
17
|
},
|
|
18
18
|
"question": {
|
|
19
19
|
"type": "string",
|
|
20
|
-
"description": "
|
|
20
|
+
"description": "Question about the codebase"
|
|
21
21
|
},
|
|
22
22
|
"top_k": {
|
|
23
23
|
"type": "integer",
|
|
24
|
-
"description": "
|
|
24
|
+
"description": "Number of relevant files to search",
|
|
25
25
|
"default": 5
|
|
26
26
|
}
|
|
27
27
|
},
|
jarvis/tools/coder.py
CHANGED
|
@@ -7,21 +7,21 @@ class CoderTool:
|
|
|
7
7
|
"""代码修改工具"""
|
|
8
8
|
|
|
9
9
|
name = "coder"
|
|
10
|
-
description = "
|
|
10
|
+
description = "Analyze and modify existing code for implementing new features, fixing bugs, refactoring code, etc. Can understand code context and perform precise code edits."
|
|
11
11
|
parameters = {
|
|
12
12
|
"feature": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"description": "
|
|
14
|
+
"description": "Description of the feature to implement or content to modify, e.g., 'add logging functionality', 'fix memory leak', 'optimize performance', etc.",
|
|
15
15
|
"required": True
|
|
16
16
|
},
|
|
17
17
|
"dir": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Project root directory, defaults to current directory",
|
|
20
20
|
"required": False
|
|
21
21
|
},
|
|
22
22
|
"language": {
|
|
23
23
|
"type": "string",
|
|
24
|
-
"description": "
|
|
24
|
+
"description": "Main programming language of the project, defaults to python",
|
|
25
25
|
"required": False
|
|
26
26
|
}
|
|
27
27
|
}
|
jarvis/tools/file_ops.py
CHANGED
|
@@ -7,7 +7,7 @@ from jarvis.utils import OutputType, PrettyOutput
|
|
|
7
7
|
|
|
8
8
|
class FileOperationTool:
|
|
9
9
|
name = "file_operation"
|
|
10
|
-
description = "
|
|
10
|
+
description = "File operations (read/write/append/exists)"
|
|
11
11
|
parameters = {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"properties": {
|
jarvis/tools/generator.py
CHANGED
|
@@ -7,25 +7,25 @@ from jarvis.utils import OutputType, PrettyOutput
|
|
|
7
7
|
|
|
8
8
|
class ToolGeneratorTool:
|
|
9
9
|
name = "generate_tool"
|
|
10
|
-
description = "
|
|
10
|
+
description = "Generate new tool code and automatically register it to Jarvis, automatically expanding Jarvis's capabilities"
|
|
11
11
|
parameters = {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"properties": {
|
|
14
14
|
"tool_name": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"description": "
|
|
16
|
+
"description": "Name of the tool (in snake_case format)"
|
|
17
17
|
},
|
|
18
18
|
"class_name": {
|
|
19
19
|
"type": "string",
|
|
20
|
-
"description": "
|
|
20
|
+
"description": "Name of the tool class (in PascalCase format)"
|
|
21
21
|
},
|
|
22
22
|
"description": {
|
|
23
23
|
"type": "string",
|
|
24
|
-
"description": "
|
|
24
|
+
"description": "Description of the tool's functionality"
|
|
25
25
|
},
|
|
26
26
|
"parameters": {
|
|
27
27
|
"type": "object",
|
|
28
|
-
"description": "
|
|
28
|
+
"description": "JSON Schema definition of tool parameters"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"required": ["tool_name", "class_name", "description", "parameters"]
|
|
@@ -44,14 +44,14 @@ class ToolGeneratorTool:
|
|
|
44
44
|
"""使用大模型生成工具代码"""
|
|
45
45
|
model = PlatformRegistry.get_global_platform_registry().get_codegen_platform()
|
|
46
46
|
|
|
47
|
-
prompt = f"""
|
|
47
|
+
prompt = f"""Please generate the code for a Python tool class, with the following requirements, and do not output any content except the code:
|
|
48
48
|
|
|
49
|
-
1.
|
|
50
|
-
2.
|
|
51
|
-
3.
|
|
52
|
-
4.
|
|
49
|
+
1. Class name: {class_name}
|
|
50
|
+
2. Tool name: {tool_name}
|
|
51
|
+
3. Function description: {description}
|
|
52
|
+
4. Parameter definition: {parameters}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
Strictly follow the following format to generate code (the parameters and return values of each function must be consistent with the example):
|
|
55
55
|
|
|
56
56
|
```python
|
|
57
57
|
from typing import Dict, Any, Protocol, Optional
|
|
@@ -60,7 +60,7 @@ from jarvis.models.registry import ModelRegistry
|
|
|
60
60
|
|
|
61
61
|
class ExampleTool:
|
|
62
62
|
name = "example_tool"
|
|
63
|
-
description = "
|
|
63
|
+
description = "Example tool"
|
|
64
64
|
parameters = {{
|
|
65
65
|
"type": "object",
|
|
66
66
|
"properties": {{
|
|
@@ -70,22 +70,22 @@ class ExampleTool:
|
|
|
70
70
|
}}
|
|
71
71
|
|
|
72
72
|
def __init__(self):
|
|
73
|
-
self.model = ModelRegistry.
|
|
73
|
+
self.model = ModelRegistry.get_global_platform_registry().get_normal_platform()
|
|
74
74
|
|
|
75
75
|
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
76
76
|
try:
|
|
77
|
-
#
|
|
77
|
+
# Validate parameter example
|
|
78
78
|
if "param1" not in args:
|
|
79
|
-
return {{"success": False, "error": "
|
|
79
|
+
return {{"success": False, "error": "Missing required parameter: param1"}}
|
|
80
80
|
|
|
81
|
-
#
|
|
82
|
-
PrettyOutput.print(f"
|
|
81
|
+
# Record operation example
|
|
82
|
+
PrettyOutput.print(f"Processing parameter: {{args['param1']}}", OutputType.INFO)
|
|
83
83
|
|
|
84
|
-
#
|
|
85
|
-
response = self.model.
|
|
84
|
+
# Use large model example
|
|
85
|
+
response = self.model.chat_until_success("prompt")
|
|
86
86
|
|
|
87
|
-
#
|
|
88
|
-
result = "
|
|
87
|
+
# Implement specific functionality
|
|
88
|
+
result = "Processing result"
|
|
89
89
|
|
|
90
90
|
return {{
|
|
91
91
|
"success": True,
|
|
@@ -101,7 +101,7 @@ class ExampleTool:
|
|
|
101
101
|
```"""
|
|
102
102
|
|
|
103
103
|
# 调用模型生成代码
|
|
104
|
-
response = model.
|
|
104
|
+
response = model.chat_until_success(prompt)
|
|
105
105
|
|
|
106
106
|
# 提取代码块
|
|
107
107
|
code_start = response.find("```python")
|
|
@@ -147,7 +147,7 @@ class ExampleTool:
|
|
|
147
147
|
f.write("# Jarvis Tools\n")
|
|
148
148
|
|
|
149
149
|
# 注册工具
|
|
150
|
-
success = ToolRegistry.get_global_tool_registry().register_tool_by_file(tool_file)
|
|
150
|
+
success = ToolRegistry.get_global_tool_registry().register_tool_by_file(str(tool_file))
|
|
151
151
|
if not success:
|
|
152
152
|
return {
|
|
153
153
|
"success": False,
|
jarvis/tools/methodology.py
CHANGED
|
@@ -8,22 +8,22 @@ class MethodologyTool:
|
|
|
8
8
|
"""经验管理工具"""
|
|
9
9
|
|
|
10
10
|
name = "methodology"
|
|
11
|
-
description = "
|
|
11
|
+
description = "Manage problem-solving methodologies, supporting add, update, and delete operations"
|
|
12
12
|
parameters = {
|
|
13
13
|
"type": "object",
|
|
14
14
|
"properties": {
|
|
15
15
|
"operation": {
|
|
16
16
|
"type": "string",
|
|
17
|
-
"description": "
|
|
17
|
+
"description": "Operation type (delete/update/add)",
|
|
18
18
|
"enum": ["delete", "update", "add"]
|
|
19
19
|
},
|
|
20
20
|
"problem_type": {
|
|
21
21
|
"type": "string",
|
|
22
|
-
"description": "
|
|
22
|
+
"description": "Problem type, e.g., code_review, bug_fix, etc."
|
|
23
23
|
},
|
|
24
24
|
"content": {
|
|
25
25
|
"type": "string",
|
|
26
|
-
"description": "
|
|
26
|
+
"description": "Methodology content (required for update/add)",
|
|
27
27
|
"optional": True
|
|
28
28
|
}
|
|
29
29
|
},
|
jarvis/tools/rag.py
CHANGED
|
@@ -5,21 +5,21 @@ from jarvis.jarvis_rag.main import RAGTool as RAGCore
|
|
|
5
5
|
|
|
6
6
|
class RAGTool:
|
|
7
7
|
name = "rag"
|
|
8
|
-
description = "
|
|
8
|
+
description = "Ask questions based on a document directory, supporting multiple document formats (txt, pdf, docx, etc.)"
|
|
9
9
|
parameters = {
|
|
10
10
|
"type": "object",
|
|
11
11
|
"properties": {
|
|
12
12
|
"dir": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"description": "
|
|
14
|
+
"description": "Document directory path, supports both relative and absolute paths"
|
|
15
15
|
},
|
|
16
16
|
"question": {
|
|
17
17
|
"type": "string",
|
|
18
|
-
"description": "
|
|
18
|
+
"description": "The question to ask"
|
|
19
19
|
},
|
|
20
20
|
"rebuild_index": {
|
|
21
21
|
"type": "boolean",
|
|
22
|
-
"description": "
|
|
22
|
+
"description": "Whether to rebuild the index",
|
|
23
23
|
"default": False
|
|
24
24
|
}
|
|
25
25
|
},
|