jarvis-ai-assistant 0.1.165__py3-none-any.whl → 0.1.166__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/jarvis_agent/__init__.py +12 -1
- jarvis/jarvis_platform/yuanbao.py +1 -0
- jarvis/jarvis_tools/edit_file.py +2 -2
- jarvis/jarvis_tools/find_methodology.py +5 -1
- jarvis/jarvis_tools/generate_new_tool.py +288 -0
- jarvis/jarvis_utils/methodology.py +11 -5
- jarvis/jarvis_utils/utils.py +1 -1
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/METADATA +41 -44
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/RECORD +14 -13
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
|
@@ -310,6 +310,17 @@ class Agent:
|
|
|
310
310
|
"""
|
|
311
311
|
self.after_tool_call_cb = cb
|
|
312
312
|
|
|
313
|
+
def get_tool_registry(self) -> Optional[ToolRegistry]:
|
|
314
|
+
"""获取工具注册器。
|
|
315
|
+
|
|
316
|
+
返回:
|
|
317
|
+
ToolRegistry: 工具注册器实例
|
|
318
|
+
"""
|
|
319
|
+
for handler in self.output_handler:
|
|
320
|
+
if isinstance(handler, ToolRegistry):
|
|
321
|
+
return handler
|
|
322
|
+
return None
|
|
323
|
+
|
|
313
324
|
def make_default_addon_prompt(self, need_complete: bool) -> str:
|
|
314
325
|
"""生成附加提示。
|
|
315
326
|
|
|
@@ -658,7 +669,7 @@ arguments:
|
|
|
658
669
|
msg = user_input
|
|
659
670
|
for handler in self.input_handler:
|
|
660
671
|
msg, _ = handler(msg, self)
|
|
661
|
-
self.prompt = f"{user_input}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg)}"
|
|
672
|
+
self.prompt = f"{user_input}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg, self.get_tool_registry())}"
|
|
662
673
|
self.first = False
|
|
663
674
|
|
|
664
675
|
while True:
|
jarvis/jarvis_tools/edit_file.py
CHANGED
|
@@ -141,7 +141,7 @@ class FileSearchReplaceTool:
|
|
|
141
141
|
content = f.read()
|
|
142
142
|
original_content = content
|
|
143
143
|
|
|
144
|
-
success, temp_content =
|
|
144
|
+
success, temp_content = patch_apply(file_path, yaml.safe_dump(changes))
|
|
145
145
|
|
|
146
146
|
# 只有当所有替换操作都成功时,才写回文件
|
|
147
147
|
if success and (temp_content != original_content or not file_exists):
|
|
@@ -208,7 +208,7 @@ class FileSearchReplaceTool:
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
|
|
211
|
-
def
|
|
211
|
+
def patch_apply(filepath: str, patch_content: str) -> Tuple[bool, str]:
|
|
212
212
|
"""执行精确的文件编辑操作,使用AI模型生成差异补丁并应用。
|
|
213
213
|
|
|
214
214
|
功能概述:
|
|
@@ -35,10 +35,14 @@ class FindMethodologyTool:
|
|
|
35
35
|
"stdout": "",
|
|
36
36
|
"stderr": "参数中必须包含查询文本"
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
agent = args.get("agent", None)
|
|
40
|
+
|
|
41
|
+
tool_registry = agent.get_tool_registry() if agent else None
|
|
38
42
|
|
|
39
43
|
with yaspin(text="搜索相关方法论...", color="cyan") as spinner:
|
|
40
44
|
with spinner.hidden():
|
|
41
|
-
methodology_prompt = load_methodology(args["query"])
|
|
45
|
+
methodology_prompt = load_methodology(args["query"], tool_registry)
|
|
42
46
|
|
|
43
47
|
if methodology_prompt:
|
|
44
48
|
spinner.text = "找到相关方法论"
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import re
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Dict, Any, Tuple
|
|
5
|
+
|
|
6
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
7
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
|
+
|
|
9
|
+
class generate_new_tool:
|
|
10
|
+
name = "generate_new_tool"
|
|
11
|
+
description = """
|
|
12
|
+
生成并注册新的Jarvis工具。该工具会在用户数据目录下创建新的工具文件,
|
|
13
|
+
并自动注册到当前的工具注册表中。适用场景:1. 需要创建新的自定义工具;
|
|
14
|
+
2. 扩展Jarvis功能;3. 自动化重复性操作;4. 封装特定领域的功能。
|
|
15
|
+
|
|
16
|
+
使用示例:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
# 创建一个将文本转换为大写/小写的工具
|
|
20
|
+
name: generate_new_tool
|
|
21
|
+
arguments:
|
|
22
|
+
tool_name: text_transformer
|
|
23
|
+
tool_code: |
|
|
24
|
+
# -*- coding: utf-8 -*-
|
|
25
|
+
from typing import Dict, Any
|
|
26
|
+
|
|
27
|
+
class text_transformer:
|
|
28
|
+
name = "text_transformer"
|
|
29
|
+
description = \"\"\"
|
|
30
|
+
文本转换工具,可以将输入的文本转换为大写、小写或首字母大写格式。
|
|
31
|
+
适用场景:1. 格式化文本; 2. 处理标题; 3. 标准化输出
|
|
32
|
+
\"\"\"
|
|
33
|
+
|
|
34
|
+
parameters = {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"text": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "需要转换格式的文本"
|
|
40
|
+
},
|
|
41
|
+
"transform_type": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "转换类型,可选值为 upper(大写)、lower(小写)或 title(首字母大写)",
|
|
44
|
+
"enum": ["upper", "lower", "title"]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": ["text", "transform_type"]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def check() -> bool:
|
|
52
|
+
return True
|
|
53
|
+
|
|
54
|
+
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
55
|
+
try:
|
|
56
|
+
text = args["text"]
|
|
57
|
+
transform_type = args["transform_type"]
|
|
58
|
+
|
|
59
|
+
if transform_type == "upper":
|
|
60
|
+
result = text.upper()
|
|
61
|
+
elif transform_type == "lower":
|
|
62
|
+
result = text.lower()
|
|
63
|
+
elif transform_type == "title":
|
|
64
|
+
result = text.title()
|
|
65
|
+
else:
|
|
66
|
+
return {
|
|
67
|
+
"success": False,
|
|
68
|
+
"stdout": "",
|
|
69
|
+
"stderr": f"不支持的转换类型: {transform_type}"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
"success": True,
|
|
74
|
+
"stdout": result,
|
|
75
|
+
"stderr": ""
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
except Exception as e:
|
|
79
|
+
return {
|
|
80
|
+
"success": False,
|
|
81
|
+
"stdout": "",
|
|
82
|
+
"stderr": f"转换失败: {str(e)}"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
创建完成后可以立即使用:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
name: text_transformer
|
|
90
|
+
arguments:
|
|
91
|
+
text: hello world
|
|
92
|
+
transform_type: upper
|
|
93
|
+
```
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
parameters = {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"tool_name": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"description": "新工具的名称,将用作文件名和工具类名"
|
|
102
|
+
},
|
|
103
|
+
"tool_code": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"description": "工具的完整Python代码,包含类定义、名称、描述、参数和execute方法"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"required": ["tool_name", "tool_code"]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@staticmethod
|
|
112
|
+
def check() -> bool:
|
|
113
|
+
"""检查工具是否可用"""
|
|
114
|
+
# 检查数据目录是否存在
|
|
115
|
+
data_dir = get_data_dir()
|
|
116
|
+
tools_dir = Path(data_dir) / "tools"
|
|
117
|
+
|
|
118
|
+
# 如果tools目录不存在,尝试创建
|
|
119
|
+
if not tools_dir.exists():
|
|
120
|
+
try:
|
|
121
|
+
tools_dir.mkdir(parents=True, exist_ok=True)
|
|
122
|
+
return True
|
|
123
|
+
except Exception as e:
|
|
124
|
+
PrettyOutput.print(f"无法创建工具目录 {tools_dir}: {e}", OutputType.ERROR)
|
|
125
|
+
return False
|
|
126
|
+
|
|
127
|
+
return True
|
|
128
|
+
|
|
129
|
+
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
130
|
+
"""
|
|
131
|
+
生成新工具并注册到当前的工具注册表中
|
|
132
|
+
|
|
133
|
+
参数:
|
|
134
|
+
args: 包含工具名称和工具代码的字典
|
|
135
|
+
|
|
136
|
+
返回:
|
|
137
|
+
Dict: 包含生成结果的字典
|
|
138
|
+
"""
|
|
139
|
+
try:
|
|
140
|
+
# 从参数中获取工具信息
|
|
141
|
+
tool_name = args["tool_name"]
|
|
142
|
+
tool_code = args["tool_code"]
|
|
143
|
+
agent = args.get("agent", None)
|
|
144
|
+
|
|
145
|
+
# 验证工具名称
|
|
146
|
+
if not tool_name.isidentifier():
|
|
147
|
+
return {
|
|
148
|
+
"success": False,
|
|
149
|
+
"stdout": "",
|
|
150
|
+
"stderr": f"工具名称 '{tool_name}' 不是有效的Python标识符"
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# 准备工具目录
|
|
154
|
+
tools_dir = Path(get_data_dir()) / "tools"
|
|
155
|
+
tools_dir.mkdir(parents=True, exist_ok=True)
|
|
156
|
+
|
|
157
|
+
# 生成工具文件路径
|
|
158
|
+
tool_file_path = tools_dir / f"{tool_name}.py"
|
|
159
|
+
|
|
160
|
+
# 检查是否已存在同名工具
|
|
161
|
+
if tool_file_path.exists():
|
|
162
|
+
return {
|
|
163
|
+
"success": False,
|
|
164
|
+
"stdout": "",
|
|
165
|
+
"stderr": f"工具 '{tool_name}' 已经存在于 {tool_file_path}"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# 验证并处理工具代码
|
|
169
|
+
processed_code, error_msg = self._validate_and_process_code(tool_name, tool_code)
|
|
170
|
+
if error_msg:
|
|
171
|
+
return {
|
|
172
|
+
"success": False,
|
|
173
|
+
"stdout": "",
|
|
174
|
+
"stderr": error_msg
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# 写入工具文件
|
|
178
|
+
with open(tool_file_path, "w", encoding="utf-8") as f:
|
|
179
|
+
f.write(processed_code)
|
|
180
|
+
|
|
181
|
+
# 注册新工具到当前的工具注册表
|
|
182
|
+
success_message = f"工具 '{tool_name}' 已成功生成在 {tool_file_path}"
|
|
183
|
+
|
|
184
|
+
if agent:
|
|
185
|
+
tool_registry = agent.get_tool_registry()
|
|
186
|
+
if tool_registry:
|
|
187
|
+
# 尝试加载并注册新工具
|
|
188
|
+
if tool_registry.register_tool_by_file(str(tool_file_path)):
|
|
189
|
+
success_message += f"\n已成功注册到当前会话的工具注册表中"
|
|
190
|
+
else:
|
|
191
|
+
success_message += f"\n注册到当前会话失败,可能需要重新启动Jarvis"
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
"success": True,
|
|
195
|
+
"stdout": success_message,
|
|
196
|
+
"stderr": ""
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
except Exception as e:
|
|
200
|
+
# 如果发生异常,返回失败响应,包含错误信息
|
|
201
|
+
return {
|
|
202
|
+
"success": False,
|
|
203
|
+
"stdout": "",
|
|
204
|
+
"stderr": f"生成工具失败: {str(e)}"
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
def _validate_and_process_code(self, tool_name: str, tool_code: str) -> Tuple[str, str]:
|
|
208
|
+
"""
|
|
209
|
+
验证并处理工具代码
|
|
210
|
+
|
|
211
|
+
参数:
|
|
212
|
+
tool_name: 工具名称
|
|
213
|
+
tool_code: 工具代码
|
|
214
|
+
|
|
215
|
+
返回:
|
|
216
|
+
Tuple[str, str]: (处理后的代码, 错误信息)
|
|
217
|
+
"""
|
|
218
|
+
# 检查工具代码中是否包含类定义
|
|
219
|
+
if f"class {tool_name}" not in tool_code:
|
|
220
|
+
# 尝试找到任何类定义
|
|
221
|
+
class_match = re.search(r"class\s+(\w+)", tool_code)
|
|
222
|
+
if class_match:
|
|
223
|
+
old_class_name = class_match.group(1)
|
|
224
|
+
# 替换类名为工具名
|
|
225
|
+
tool_code = tool_code.replace(f"class {old_class_name}", f"class {tool_name}")
|
|
226
|
+
tool_code = tool_code.replace(f'name = "{old_class_name}"', f'name = "{tool_name}"')
|
|
227
|
+
else:
|
|
228
|
+
# 没有找到类定义,返回错误
|
|
229
|
+
return "", f"工具代码中缺少类定义 'class {tool_name}'"
|
|
230
|
+
|
|
231
|
+
# 检查工具代码中是否包含必要的属性和方法
|
|
232
|
+
missing_components = []
|
|
233
|
+
|
|
234
|
+
if f'name = "{tool_name}"' not in tool_code and f"name = '{tool_name}'" not in tool_code:
|
|
235
|
+
# 尝试查找任何name属性并修复
|
|
236
|
+
name_match = re.search(r'name\s*=\s*["\'](\w+)["\']', tool_code)
|
|
237
|
+
if name_match:
|
|
238
|
+
old_name = name_match.group(1)
|
|
239
|
+
tool_code = re.sub(r'name\s*=\s*["\'](\w+)["\']', f'name = "{tool_name}"', tool_code)
|
|
240
|
+
else:
|
|
241
|
+
missing_components.append(f"name = \"{tool_name}\"")
|
|
242
|
+
|
|
243
|
+
if "description = " not in tool_code:
|
|
244
|
+
missing_components.append("description 属性")
|
|
245
|
+
|
|
246
|
+
if "parameters = " not in tool_code:
|
|
247
|
+
missing_components.append("parameters 属性")
|
|
248
|
+
|
|
249
|
+
if "def execute(self, args:" not in tool_code:
|
|
250
|
+
missing_components.append("execute 方法")
|
|
251
|
+
|
|
252
|
+
if "def check(" not in tool_code:
|
|
253
|
+
# 添加默认的check方法
|
|
254
|
+
class_match = re.search(r"class\s+(\w+).*?:", tool_code, re.DOTALL)
|
|
255
|
+
if class_match:
|
|
256
|
+
indent = " " # 默认缩进
|
|
257
|
+
# 找到类定义后的第一个属性
|
|
258
|
+
first_attr_match = re.search(r"class\s+(\w+).*?:(.*?)(\w+\s*=)", tool_code, re.DOTALL)
|
|
259
|
+
if first_attr_match:
|
|
260
|
+
# 获取属性前的缩进
|
|
261
|
+
attr_indent = re.search(r"\n([ \t]*)\w+\s*=", first_attr_match.group(2))
|
|
262
|
+
if attr_indent:
|
|
263
|
+
indent = attr_indent.group(1)
|
|
264
|
+
|
|
265
|
+
check_method = f"\n{indent}@staticmethod\n{indent}def check() -> bool:\n{indent} \"\"\"检查工具是否可用\"\"\"\n{indent} return True\n"
|
|
266
|
+
|
|
267
|
+
# 在类定义后插入check方法
|
|
268
|
+
pattern = r"(class\s+(\w+).*?:.*?)(\n\s*\w+\s*=|\n\s*@|\n\s*def)"
|
|
269
|
+
replacement = r"\1" + check_method + r"\3"
|
|
270
|
+
tool_code = re.sub(pattern, replacement, tool_code, 1, re.DOTALL)
|
|
271
|
+
|
|
272
|
+
# 如果缺少必要组件,返回错误信息
|
|
273
|
+
if missing_components:
|
|
274
|
+
return "", f"工具代码中缺少以下必要组件: {', '.join(missing_components)}"
|
|
275
|
+
|
|
276
|
+
# 确保代码有正确的Python文件头部
|
|
277
|
+
if not tool_code.startswith("# -*- coding:") and not tool_code.startswith("# coding="):
|
|
278
|
+
tool_code = "# -*- coding: utf-8 -*-\n" + tool_code
|
|
279
|
+
|
|
280
|
+
# 确保导入了必要的模块
|
|
281
|
+
if "from typing import Dict, Any" not in tool_code:
|
|
282
|
+
imports_pos = tool_code.find("\n\n")
|
|
283
|
+
if imports_pos > 0:
|
|
284
|
+
tool_code = tool_code[:imports_pos] + "\nfrom typing import Dict, Any" + tool_code[imports_pos:]
|
|
285
|
+
else:
|
|
286
|
+
tool_code = "from typing import Dict, Any\n\n" + tool_code
|
|
287
|
+
|
|
288
|
+
return tool_code, ""
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import os
|
|
11
11
|
import json
|
|
12
12
|
import tempfile
|
|
13
|
-
from typing import Dict, Optional
|
|
13
|
+
from typing import Any, Dict, Optional
|
|
14
14
|
|
|
15
15
|
from jarvis.jarvis_utils.config import get_data_dir
|
|
16
16
|
from jarvis.jarvis_utils.output import PrettyOutput, OutputType
|
|
@@ -92,7 +92,7 @@ def _create_methodology_temp_file(methodologies: Dict[str, str]) -> Optional[str
|
|
|
92
92
|
PrettyOutput.print(f"创建方法论临时文件失败: {str(e)}", OutputType.ERROR)
|
|
93
93
|
return None
|
|
94
94
|
|
|
95
|
-
def load_methodology(user_input: str) -> str:
|
|
95
|
+
def load_methodology(user_input: str, tool_registery: Optional[Any] = None) -> str:
|
|
96
96
|
"""
|
|
97
97
|
加载方法论并上传到大模型。
|
|
98
98
|
|
|
@@ -103,6 +103,9 @@ def load_methodology(user_input: str) -> str:
|
|
|
103
103
|
str: 相关的方法论提示,如果未找到方法论则返回空字符串
|
|
104
104
|
"""
|
|
105
105
|
from yaspin import yaspin # type: ignore
|
|
106
|
+
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
107
|
+
|
|
108
|
+
prompt = tool_registery.prompt() if tool_registery else ""
|
|
106
109
|
|
|
107
110
|
# 获取方法论目录
|
|
108
111
|
methodology_dir = _get_methodology_directory()
|
|
@@ -133,10 +136,13 @@ def load_methodology(user_input: str) -> str:
|
|
|
133
136
|
full_content = base_prompt
|
|
134
137
|
for problem_type, content in methodologies.items():
|
|
135
138
|
full_content += f"## {problem_type}\n\n{content}\n\n---\n\n"
|
|
139
|
+
|
|
140
|
+
full_content += f"以下是所有可用的工具内容:\n\n"
|
|
141
|
+
full_content += prompt
|
|
136
142
|
|
|
137
143
|
# 添加用户输入和输出要求
|
|
138
144
|
full_content += f"""
|
|
139
|
-
|
|
145
|
+
请根据以上方法论和可调用的工具内容,规划/总结出以下用户需求的执行步骤: {user_input}
|
|
140
146
|
|
|
141
147
|
请按以下格式回复:
|
|
142
148
|
### 与该任务/需求相关的方法论
|
|
@@ -175,7 +181,7 @@ def load_methodology(user_input: str) -> str:
|
|
|
175
181
|
if upload_success:
|
|
176
182
|
# 使用上传的文件生成摘要
|
|
177
183
|
return platform.chat_until_success(base_prompt + f"""
|
|
178
|
-
|
|
184
|
+
请根据已上传的方法论和可调用的工具文件内容,规划/总结出以下用户需求的执行步骤: {user_input}
|
|
179
185
|
|
|
180
186
|
请按以下格式回复:
|
|
181
187
|
### 与该任务/需求相关的方法论
|
|
@@ -192,7 +198,7 @@ def load_methodology(user_input: str) -> str:
|
|
|
192
198
|
elif hasattr(platform, 'chat_big_content'):
|
|
193
199
|
# 如果上传失败但支持大内容处理,使用chat_big_content
|
|
194
200
|
return platform.chat_big_content(full_content, base_prompt + f"""
|
|
195
|
-
|
|
201
|
+
请根据以上方法论和可调用的工具文件内容,规划/总结出以下用户需求的执行步骤: {user_input}
|
|
196
202
|
|
|
197
203
|
请按以下格式回复:
|
|
198
204
|
### 与该任务/需求相关的方法论
|
jarvis/jarvis_utils/utils.py
CHANGED
|
@@ -66,7 +66,7 @@ def while_success(func: Callable[[], Any], sleep_time: float = 0.1) -> Any:
|
|
|
66
66
|
try:
|
|
67
67
|
return func()
|
|
68
68
|
except Exception as e:
|
|
69
|
-
PrettyOutput.print(f"执行失败: {str(e)}, 等待 {sleep_time}s...", OutputType.
|
|
69
|
+
PrettyOutput.print(f"执行失败: {str(e)}, 等待 {sleep_time}s...", OutputType.WARNING)
|
|
70
70
|
time.sleep(sleep_time)
|
|
71
71
|
continue
|
|
72
72
|
def while_true(func: Callable[[], bool], sleep_time: float = 0.1) -> Any:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.166
|
|
4
4
|
Summary: Jarvis: An AI assistant that uses tools to interact with the system
|
|
5
5
|
Home-page: https://github.com/skyfireitdiy/Jarvis
|
|
6
6
|
Author: skyfire
|
|
@@ -106,11 +106,19 @@ Dynamic: requires-python
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
## 🚀 快速开始 <a id="quick-start"></a>
|
|
109
|
+
### 系统要求
|
|
110
|
+
- 目前只能在Linux系统下使用(很多工具依赖Linux系统)
|
|
111
|
+
- Windows没有测试过,但Windows 10以上的用户可以在WSL上使用此工具
|
|
112
|
+
|
|
109
113
|
### 安装
|
|
110
114
|
```bash
|
|
115
|
+
# 从源码安装(推荐)
|
|
111
116
|
git clone https://github.com/skyfireitdiy/Jarvis
|
|
112
117
|
cd Jarvis
|
|
113
118
|
pip3 install -e .
|
|
119
|
+
|
|
120
|
+
# 或者从PyPI安装(可能更新不及时)
|
|
121
|
+
pip3 install jarvis-ai-assistant
|
|
114
122
|
```
|
|
115
123
|
|
|
116
124
|
### 最小化配置
|
|
@@ -149,55 +157,44 @@ Kimi API Key获取方式:
|
|
|
149
157
|
|
|
150
158
|
删除Bearer前缀,剩下的内容就是Kimi API Key。
|
|
151
159
|
|
|
152
|
-
以上配置编写到`~/.jarvis/env`文件中。
|
|
153
160
|
|
|
154
|
-
|
|
161
|
+
#### OpenAI
|
|
155
162
|
```bash
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
#
|
|
164
|
-
|
|
165
|
-
# 或者 jss
|
|
166
|
-
|
|
167
|
-
# 使用平台管理的功能
|
|
168
|
-
jarvis-platform-manager --help
|
|
169
|
-
|
|
170
|
-
# 使用代码审查的功能
|
|
171
|
-
jarvis-code-review --help
|
|
172
|
-
|
|
173
|
-
# 使用自动化git commit的功能
|
|
174
|
-
jarvis-git-commit --help
|
|
175
|
-
# 或者 jgc
|
|
176
|
-
|
|
177
|
-
# 使用dev功能(开发中)
|
|
178
|
-
jarvis-dev --help
|
|
179
|
-
|
|
180
|
-
# 使用git squash的功能
|
|
181
|
-
jarvis-git-squash --help
|
|
182
|
-
|
|
183
|
-
# 使用多代理的功能
|
|
184
|
-
jarvis-multi-agent --help
|
|
185
|
-
|
|
186
|
-
# 使用agent的功能
|
|
187
|
-
jarvis-agent --help
|
|
163
|
+
JARVIS_PLATFORM=openai
|
|
164
|
+
JARVIS_MODEL=gpt-4o # 默认模型,可选gpt-4-turbo, gpt-3.5-turbo等
|
|
165
|
+
JARVIS_THINKING_PLATFORM=openai
|
|
166
|
+
JARVIS_THINKING_MODEL=gpt-4o
|
|
167
|
+
|
|
168
|
+
OPENAI_API_KEY=<OpenAI API Key>
|
|
169
|
+
OPENAI_API_BASE=https://api.openai.com/v1 # 可选,默认为官方API地址
|
|
170
|
+
OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
|
|
171
|
+
```
|
|
188
172
|
|
|
189
|
-
|
|
190
|
-
|
|
173
|
+
配置说明:
|
|
174
|
+
1. `OPENAI_API_KEY`: 必填。
|
|
175
|
+
2. `OPENAI_API_BASE`: 可选,用于自定义API端点
|
|
191
176
|
|
|
192
|
-
|
|
193
|
-
jarvis-ask-codebase --help
|
|
177
|
+
以上配置编写到`~/.jarvis/env`文件中。
|
|
194
178
|
|
|
195
|
-
|
|
196
|
-
jarvis-git-details --help
|
|
179
|
+
支持的模型可通过`jarvis-platform-manager --list-models`查看完整列表。
|
|
197
180
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
181
|
+
### 基本使用
|
|
182
|
+
| 命令 | 快捷方式 | 功能描述 |
|
|
183
|
+
|------|----------|----------|
|
|
184
|
+
| `jarvis` | - | 使用通用代理 |
|
|
185
|
+
| `jarvis-code-agent` | `jca` | 使用代码代理 |
|
|
186
|
+
| `jarvis-smart-shell` | `jss` | 使用智能shell功能 |
|
|
187
|
+
| `jarvis-platform-manager` | - | 使用平台管理功能 |
|
|
188
|
+
| `jarvis-code-review` | - | 使用代码审查功能 |
|
|
189
|
+
| `jarvis-git-commit` | `jgc` | 使用自动化git commit功能 |
|
|
190
|
+
| `jarvis-dev` | - | 使用dev功能(开发中) |
|
|
191
|
+
| `jarvis-git-squash` | - | 使用git squash功能 |
|
|
192
|
+
| `jarvis-multi-agent` | - | 使用多代理功能 |
|
|
193
|
+
| `jarvis-agent` | - | 使用agent功能 |
|
|
194
|
+
| `jarvis-tool` | - | 使用工具功能 |
|
|
195
|
+
| `jarvis-ask-codebase` | `jac` | 使用代码库查询功能 |
|
|
196
|
+
| `jarvis-git-details` | - | 使用git details功能 |
|
|
197
|
+
| `jarvis-methodology` | - | 使用方法论功能 |
|
|
201
198
|
|
|
202
199
|
---
|
|
203
200
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
jarvis/__init__.py,sha256=
|
|
2
|
-
jarvis/jarvis_agent/__init__.py,sha256=
|
|
1
|
+
jarvis/__init__.py,sha256=0Fntb2U8kfsGlgEEg53GQ59fxHbqHyr4xwmnHxiRhFE,74
|
|
2
|
+
jarvis/jarvis_agent/__init__.py,sha256=B8xzwscC6f9tDorcwtblQlR-sptgFxxBlG2KADc7q0E,25711
|
|
3
3
|
jarvis/jarvis_agent/builtin_input_handler.py,sha256=KhvlV_QdB3P-M0TCkWvdxidNie1jU7KoMOqTIXCpwwA,1529
|
|
4
4
|
jarvis/jarvis_agent/file_input_handler.py,sha256=EwaitWczbwLCKNpWU9C7m829_G5uLZ_hNcVXlX2ANes,3437
|
|
5
5
|
jarvis/jarvis_agent/jarvis.py,sha256=rn0rLMGuVDyUa0_xdAmPV3M4yhIvE9ldSwD5DaJKo-8,5819
|
|
@@ -54,7 +54,7 @@ jarvis/jarvis_platform/human.py,sha256=0sbEhST4rKKGGV45dAdJqvVBnRPPeCe6HqxR245S4
|
|
|
54
54
|
jarvis/jarvis_platform/kimi.py,sha256=c9OglWXt-B7FU-Yn60b_wZo4SFX5jMI_RxD4SAh2fVA,16691
|
|
55
55
|
jarvis/jarvis_platform/openai.py,sha256=8enxCISjHtCs0qoqEag68v68m_clKr7jgEpUA0CyUBo,4139
|
|
56
56
|
jarvis/jarvis_platform/registry.py,sha256=UjCdPT9WIRxU-F0uuPpKmKRRCcNNxjr-bRTEPgRSNx4,7740
|
|
57
|
-
jarvis/jarvis_platform/yuanbao.py,sha256=
|
|
57
|
+
jarvis/jarvis_platform/yuanbao.py,sha256=EkcpXzK5svBZZE_wE6T8b7buDMJF3NDrZUB-2636W6c,21929
|
|
58
58
|
jarvis/jarvis_platform_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
jarvis/jarvis_platform_manager/main.py,sha256=gFqXKNweU9mE-IRqV7qhXmZ5483D01s9bI76POX1uXc,22596
|
|
60
60
|
jarvis/jarvis_smart_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -67,11 +67,12 @@ jarvis/jarvis_tools/chdir.py,sha256=wYVBqWF5kaUkKqH3cUAOKUsACzYsFtCCJJyd8UJsp4o,
|
|
|
67
67
|
jarvis/jarvis_tools/code_plan.py,sha256=EzLdbJnVCkJ7lL8XIQyuDJdxU1i3CFiBpqyNG-GdJw8,7753
|
|
68
68
|
jarvis/jarvis_tools/create_code_agent.py,sha256=cxYkjr4rhI2EWpK78psZSRB9mxiP1IUT0SEfFIqCJzY,3411
|
|
69
69
|
jarvis/jarvis_tools/create_sub_agent.py,sha256=ppTOFRd0ygSJUFr3oQ8IrCLOqbZ7vwnbdadfTDjpDgs,3025
|
|
70
|
-
jarvis/jarvis_tools/edit_file.py,sha256=
|
|
70
|
+
jarvis/jarvis_tools/edit_file.py,sha256=1SllJmc-1gHf8h8xwQylJs84Ac0xowVpg0-X6yabwkM,13827
|
|
71
71
|
jarvis/jarvis_tools/execute_script.py,sha256=cc0NlPwhkZinEexqT63d1ofEkzQddVWGsZOCVL1v_60,5739
|
|
72
72
|
jarvis/jarvis_tools/file_analyzer.py,sha256=tzU1cPKyDa54hVZewP0bDzdsjvdjGQ1BRt5k8N4li3s,4868
|
|
73
73
|
jarvis/jarvis_tools/file_operation.py,sha256=lP8EpsnSdA3FW8ofSAdoA8qPGMAG3UhYd6LFEzOFUVY,9044
|
|
74
|
-
jarvis/jarvis_tools/find_methodology.py,sha256=
|
|
74
|
+
jarvis/jarvis_tools/find_methodology.py,sha256=FwGKSV4fHNkiAnaVUwP8GkqXl8PEqMPZBxAyvTSPFGA,2438
|
|
75
|
+
jarvis/jarvis_tools/generate_new_tool.py,sha256=On4dXSmZZ_rVkNaZ151QE_3OWXXqtjs0lC-Dmxv9jSQ,11572
|
|
75
76
|
jarvis/jarvis_tools/lsp_get_diagnostics.py,sha256=paz1CVZ2Y8nk0U74n1QiG01oDINiZqpVlPc2f4_B150,5346
|
|
76
77
|
jarvis/jarvis_tools/methodology.py,sha256=Md8W2et0xUiuTjUSRCdnlwEPYqah2dCAAkxW_95BXBY,5238
|
|
77
78
|
jarvis/jarvis_tools/read_code.py,sha256=pgztSBRh8RORFalqwzzsLHQogooFvDm1ePBL0E5O1C4,5961
|
|
@@ -88,13 +89,13 @@ jarvis/jarvis_utils/file_processors.py,sha256=tSZSMJ4qCJ_lXI0dyLgJ0j5qEh6CDXDSVI
|
|
|
88
89
|
jarvis/jarvis_utils/git_utils.py,sha256=FSKu6YBOkb_-zHU35gicYTjPLk0H4XMq5kdUP5wSzwE,9980
|
|
89
90
|
jarvis/jarvis_utils/globals.py,sha256=Zs0chxA_giYiolYvawFFpcnTWgCUnn6GEusAh42jbz8,2275
|
|
90
91
|
jarvis/jarvis_utils/input.py,sha256=qGf2q-yWhgT-OX-j_WYi7aZ11jYmuFNiMz2_W1nUOiM,7432
|
|
91
|
-
jarvis/jarvis_utils/methodology.py,sha256=
|
|
92
|
+
jarvis/jarvis_utils/methodology.py,sha256=d25o61UtnuwgIQBgnajxx9zPsxsVzv4Ptb9BGwC93Nk,8156
|
|
92
93
|
jarvis/jarvis_utils/output.py,sha256=PVG4fQ3P-eGOZUNZTowPtnjqq3GN91OE8fHa68lFOOg,8440
|
|
93
94
|
jarvis/jarvis_utils/tag.py,sha256=YJHmuedLb7_AiqvKQetHr4R1FxyzIh7HN0RRkWMmYbU,429
|
|
94
|
-
jarvis/jarvis_utils/utils.py,sha256=
|
|
95
|
-
jarvis_ai_assistant-0.1.
|
|
96
|
-
jarvis_ai_assistant-0.1.
|
|
97
|
-
jarvis_ai_assistant-0.1.
|
|
98
|
-
jarvis_ai_assistant-0.1.
|
|
99
|
-
jarvis_ai_assistant-0.1.
|
|
100
|
-
jarvis_ai_assistant-0.1.
|
|
95
|
+
jarvis/jarvis_utils/utils.py,sha256=TY-2hYKq_ip9TET671o_mgfpdb5mQw_W5NQMsTnBdcU,5250
|
|
96
|
+
jarvis_ai_assistant-0.1.166.dist-info/licenses/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
97
|
+
jarvis_ai_assistant-0.1.166.dist-info/METADATA,sha256=t_lVdOXLej8bnfr78mwWBohcUSObTFqUZc5_3-nkbgk,14323
|
|
98
|
+
jarvis_ai_assistant-0.1.166.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
99
|
+
jarvis_ai_assistant-0.1.166.dist-info/entry_points.txt,sha256=cKz_9SEpOvElTubKPMZMAdskD4GHz-NyKWRNssIVAWE,973
|
|
100
|
+
jarvis_ai_assistant-0.1.166.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
101
|
+
jarvis_ai_assistant-0.1.166.dist-info/RECORD,,
|
|
File without changes
|
{jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.165.dist-info → jarvis_ai_assistant-0.1.166.dist-info}/top_level.txt
RENAMED
|
File without changes
|