jarvis-ai-assistant 0.1.59__py3-none-any.whl → 0.1.61__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 +39 -15
- jarvis/models/ai8.py +1 -1
- jarvis/models/openai.py +1 -1
- jarvis/models/oyi.py +1 -1
- jarvis/models/registry.py +5 -4
- jarvis/tools/coder.py +7 -4
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/METADATA +1 -1
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/RECORD +13 -13
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/agent.py
CHANGED
|
@@ -25,7 +25,7 @@ class Agent:
|
|
|
25
25
|
self.name = name
|
|
26
26
|
self.is_sub_agent = is_sub_agent
|
|
27
27
|
self.prompt = ""
|
|
28
|
-
self.conversation_turns = 0
|
|
28
|
+
self.conversation_turns = 0
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
@staticmethod
|
|
@@ -88,17 +88,15 @@ class Agent:
|
|
|
88
88
|
continue
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def _load_methodology(self) -> str:
|
|
92
|
-
"""
|
|
91
|
+
def _load_methodology(self) -> Dict[str, str]:
|
|
92
|
+
"""加载方法论"""
|
|
93
93
|
user_jarvis_methodology = os.path.expanduser("~/.jarvis_methodology")
|
|
94
|
-
ret = ""
|
|
95
94
|
if os.path.exists(user_jarvis_methodology):
|
|
96
95
|
with open(user_jarvis_methodology, "r", encoding="utf-8") as f:
|
|
97
96
|
data = yaml.safe_load(f)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return ret
|
|
97
|
+
PrettyOutput.print(f"从 {user_jarvis_methodology} 加载方法论: {', '.join(data.keys())}", OutputType.INFO)
|
|
98
|
+
return data
|
|
99
|
+
return {}
|
|
102
100
|
|
|
103
101
|
def _summarize_and_clear_history(self) -> None:
|
|
104
102
|
"""总结当前对话历史并清空历史记录,只保留系统消息和总结
|
|
@@ -144,6 +142,28 @@ class Agent:
|
|
|
144
142
|
except Exception as e:
|
|
145
143
|
PrettyOutput.print(f"总结对话历史失败: {str(e)}", OutputType.ERROR)
|
|
146
144
|
|
|
145
|
+
def _make_mathodology(self) -> str:
|
|
146
|
+
PrettyOutput.section("生成方法论", OutputType.PLANNING)
|
|
147
|
+
"""生成方法论"""
|
|
148
|
+
prompt = f"""任务已经结束,请总结任务执行过程中的经验,评估是否需要补充新的方法论,如果需要,请调用方法论工具生成方法论,方法论内容格式如下:
|
|
149
|
+
|
|
150
|
+
1. 问题重述
|
|
151
|
+
2. 最优解决方案
|
|
152
|
+
3. 最优方案执行步骤(失败的行动不需要体现)
|
|
153
|
+
"""
|
|
154
|
+
return self._call_model(prompt)
|
|
155
|
+
|
|
156
|
+
def _choose_methodology(self, methodology: Dict[str, str], task: str) -> str:
|
|
157
|
+
"""选择方法论"""
|
|
158
|
+
prompt = f"""请根据任务内容选择合适的方法论,并返回方法论内容,格式如下:
|
|
159
|
+
任务内容:
|
|
160
|
+
{task}
|
|
161
|
+
|
|
162
|
+
方法论:
|
|
163
|
+
{methodology}
|
|
164
|
+
"""
|
|
165
|
+
return self._call_model(prompt)
|
|
166
|
+
|
|
147
167
|
def _complete_task(self) -> str:
|
|
148
168
|
"""完成任务并生成总结
|
|
149
169
|
|
|
@@ -151,6 +171,8 @@ class Agent:
|
|
|
151
171
|
str: 任务总结或完成状态
|
|
152
172
|
"""
|
|
153
173
|
PrettyOutput.section("任务完成", OutputType.SUCCESS)
|
|
174
|
+
|
|
175
|
+
self._make_mathodology()
|
|
154
176
|
|
|
155
177
|
if not self.is_sub_agent:
|
|
156
178
|
return "Task completed"
|
|
@@ -181,21 +203,23 @@ class Agent:
|
|
|
181
203
|
str: 任务总结报告
|
|
182
204
|
"""
|
|
183
205
|
try:
|
|
184
|
-
self.clear_history()
|
|
185
|
-
self.conversation_turns = 0 # 重置对话轮次
|
|
186
|
-
|
|
187
206
|
if file_list:
|
|
188
207
|
self.model.upload_files(file_list)
|
|
189
208
|
|
|
190
|
-
#
|
|
209
|
+
# 加载方法论
|
|
191
210
|
methodology = self._load_methodology()
|
|
192
211
|
|
|
212
|
+
methodology =self._choose_methodology(methodology, user_input)
|
|
213
|
+
|
|
193
214
|
methodology_prompt = ""
|
|
194
215
|
if methodology:
|
|
195
|
-
methodology_prompt = f"""
|
|
216
|
+
methodology_prompt = f"""这是以往处理问题的标准方法论,如果当前任务与此类似,可参考:
|
|
196
217
|
{methodology}
|
|
197
218
|
|
|
198
219
|
"""
|
|
220
|
+
|
|
221
|
+
self.clear_history()
|
|
222
|
+
self.conversation_turns = 0
|
|
199
223
|
|
|
200
224
|
# 显示任务开始
|
|
201
225
|
PrettyOutput.section(f"开始新任务: {self.name}", OutputType.PLANNING)
|
|
@@ -217,11 +241,11 @@ class Agent:
|
|
|
217
241
|
6. 制定行动计划:根据目前可以使用的工具制定行动计划
|
|
218
242
|
7. 执行行动计划:每步执行一个步骤,最多使用一个工具(工具执行完成后,等待工具结果再执行下一步)
|
|
219
243
|
8. 监控与调整:如果执行结果与预期不符,则反思并调整行动计划,迭代之前的步骤
|
|
220
|
-
9.
|
|
244
|
+
9. 方法论:如果当前任务具有通用性且执行过程中遇到了值得记录的经验,使用方法论工具记录方法论,以提升后期处理类似问题的能力
|
|
221
245
|
10. 任务结束:如果任务已经完成,使用任务结束指令结束任务
|
|
222
246
|
-------------------------------------------------------------
|
|
223
247
|
|
|
224
|
-
|
|
248
|
+
方法论模板:
|
|
225
249
|
1. 问题重述
|
|
226
250
|
2. 最优解决方案
|
|
227
251
|
3. 最优方案执行步骤(失败的行动不需要体现)
|
jarvis/models/ai8.py
CHANGED
jarvis/models/openai.py
CHANGED
jarvis/models/oyi.py
CHANGED
jarvis/models/registry.py
CHANGED
|
@@ -29,7 +29,8 @@ class PlatformRegistry:
|
|
|
29
29
|
# 创建 __init__.py 使其成为 Python 包
|
|
30
30
|
with open(os.path.join(user_platform_dir, "__init__.py"), "w") as f:
|
|
31
31
|
pass
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
pass
|
|
33
34
|
except Exception as e:
|
|
34
35
|
PrettyOutput.print(f"创建平台目录失败: {str(e)}", OutputType.ERROR)
|
|
35
36
|
return ""
|
|
@@ -120,8 +121,8 @@ class PlatformRegistry:
|
|
|
120
121
|
# 检查平台实现
|
|
121
122
|
if not PlatformRegistry.check_platform_implementation(obj):
|
|
122
123
|
continue
|
|
124
|
+
|
|
123
125
|
platforms[obj.platform_name] = obj
|
|
124
|
-
PrettyOutput.print(f"从 {directory} 加载平台: {obj.platform_name}", OutputType.INFO)
|
|
125
126
|
break
|
|
126
127
|
except Exception as e:
|
|
127
128
|
PrettyOutput.print(f"加载平台 {module_name} 失败: {str(e)}", OutputType.ERROR)
|
|
@@ -159,6 +160,7 @@ class PlatformRegistry:
|
|
|
159
160
|
raise Exception(f"Failed to create platform: {PlatformRegistry.global_platform_name}")
|
|
160
161
|
return platform
|
|
161
162
|
|
|
163
|
+
|
|
162
164
|
def register_platform(self, name: str, platform_class: Type[BasePlatform]):
|
|
163
165
|
"""注册平台类
|
|
164
166
|
|
|
@@ -167,7 +169,6 @@ class PlatformRegistry:
|
|
|
167
169
|
model_class: 平台类
|
|
168
170
|
"""
|
|
169
171
|
self.platforms[name] = platform_class
|
|
170
|
-
PrettyOutput.print(f"已注册平台: {name}", OutputType.INFO)
|
|
171
172
|
|
|
172
173
|
def create_platform(self, name: str) -> Optional[BasePlatform]:
|
|
173
174
|
"""创建平台实例
|
|
@@ -183,8 +184,8 @@ class PlatformRegistry:
|
|
|
183
184
|
return None
|
|
184
185
|
|
|
185
186
|
try:
|
|
187
|
+
|
|
186
188
|
platform = self.platforms[name]()
|
|
187
|
-
PrettyOutput.print(f"已创建平台实例: {name}", OutputType.INFO)
|
|
188
189
|
return platform
|
|
189
190
|
except Exception as e:
|
|
190
191
|
PrettyOutput.print(f"创建平台失败: {str(e)}", OutputType.ERROR)
|
jarvis/tools/coder.py
CHANGED
|
@@ -26,6 +26,9 @@ class CoderTool:
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
def __init__(self):
|
|
30
|
+
self._coder = None
|
|
31
|
+
|
|
29
32
|
|
|
30
33
|
def _init_coder(self, dir: Optional[str] = None, language: Optional[str] = "python") -> None:
|
|
31
34
|
"""初始化JarvisCoder实例"""
|
|
@@ -34,7 +37,7 @@ class CoderTool:
|
|
|
34
37
|
work_dir = dir or os.getcwd()
|
|
35
38
|
self._coder = JarvisCoder(work_dir, language)
|
|
36
39
|
|
|
37
|
-
def execute(self,
|
|
40
|
+
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
38
41
|
"""执行代码修改
|
|
39
42
|
|
|
40
43
|
Args:
|
|
@@ -45,9 +48,9 @@ class CoderTool:
|
|
|
45
48
|
Returns:
|
|
46
49
|
Dict[str, Any]: 执行结果
|
|
47
50
|
"""
|
|
48
|
-
feature =
|
|
49
|
-
dir =
|
|
50
|
-
language =
|
|
51
|
+
feature = args.get("feature")
|
|
52
|
+
dir = args.get("dir")
|
|
53
|
+
language = args.get("language", "python")
|
|
51
54
|
|
|
52
55
|
try:
|
|
53
56
|
self.current_dir = os.getcwd()
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
jarvis/__init__.py,sha256=
|
|
2
|
-
jarvis/agent.py,sha256=
|
|
1
|
+
jarvis/__init__.py,sha256=hXWmKj3rApgD-Yzo4jt2kZEsepnNS-DfVUFCBFc79b0,50
|
|
2
|
+
jarvis/agent.py,sha256=rL3QMLD-48KMrRmiq8eU9T4ftdJdYVLg48e7df5Mg4E,14660
|
|
3
3
|
jarvis/main.py,sha256=gXXtnrkkvGwEswJL6qiYjVrg3bpzye-GJeAe0Nf2B9o,6509
|
|
4
4
|
jarvis/utils.py,sha256=JlkuC9RtspXH2VWDmj9nR0vnb8ie1gIsKc4vC7WRco8,7321
|
|
5
5
|
jarvis/jarvis_coder/main.py,sha256=TosDDiaYSjDpzKPNKcygxZ3XXWbcnvBmIIMn3UMBc60,35102
|
|
6
6
|
jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
|
|
7
|
-
jarvis/models/ai8.py,sha256=
|
|
7
|
+
jarvis/models/ai8.py,sha256=AMBZRS9hKW1Ts_YoHMMelhT0CRMeMzHtVH31z0FpP-Q,12671
|
|
8
8
|
jarvis/models/base.py,sha256=ShV1H8Unee4RMaiFO4idROQA0Hc6wu4dyeRPX5fcszk,1433
|
|
9
9
|
jarvis/models/kimi.py,sha256=1iTB0Z_WOmCML3Ufsge6jmeKOYvccr7I5lS3JUXymU4,17611
|
|
10
|
-
jarvis/models/openai.py,sha256=
|
|
11
|
-
jarvis/models/oyi.py,sha256=
|
|
12
|
-
jarvis/models/registry.py,sha256=
|
|
10
|
+
jarvis/models/openai.py,sha256=7oOxrL6EM7iaqJgZsaFvVmyzY0ars4BP3EKAUlX1RPw,4403
|
|
11
|
+
jarvis/models/oyi.py,sha256=mW-uhUZbts2L_oI8WueZUTEmrLY1CiBHn4UV2HP7ZCE,15214
|
|
12
|
+
jarvis/models/registry.py,sha256=hJyaROiOF_TkbtIXsjOD8-ArOvAvtxviawyqBFfLV6s,7617
|
|
13
13
|
jarvis/tools/__init__.py,sha256=Kj1bKj34lwRDKMKHLOrLyQElf2lHbqA2tDgP359eaDo,71
|
|
14
14
|
jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
|
|
15
|
-
jarvis/tools/coder.py,sha256=
|
|
15
|
+
jarvis/tools/coder.py,sha256=ZJfPInKms4Hj3-eQlBwamVsvZ-2nlZ-4jsqJ-tJc6mg,2040
|
|
16
16
|
jarvis/tools/file_ops.py,sha256=h8g0eT9UvlJf4kt0DLXvdSsjcPj7x19lxWdDApeDfpg,3842
|
|
17
17
|
jarvis/tools/generator.py,sha256=vVP3eN5cCDpRXf_fn0skETkPXAW1XZFWx9pt2_ahK48,5999
|
|
18
18
|
jarvis/tools/methodology.py,sha256=G3cOaHTMujGZBhDLhQEqyCV2NISizO3MXRuho1KfI6Y,5223
|
|
@@ -21,9 +21,9 @@ jarvis/tools/search.py,sha256=1EqOVvLhg2Csh-i03-XeCrusbyfmH69FZ8khwZt8Tow,6131
|
|
|
21
21
|
jarvis/tools/shell.py,sha256=UPKshPyOaUwTngresUw-ot1jHjQIb4wCY5nkJqa38lU,2520
|
|
22
22
|
jarvis/tools/sub_agent.py,sha256=rEtAmSVY2ZjFOZEKr5m5wpACOQIiM9Zr_3dT92FhXYU,2621
|
|
23
23
|
jarvis/tools/webpage.py,sha256=d3w3Jcjcu1ESciezTkz3n3Zf-rp_l91PrVoDEZnckOo,2391
|
|
24
|
-
jarvis_ai_assistant-0.1.
|
|
25
|
-
jarvis_ai_assistant-0.1.
|
|
26
|
-
jarvis_ai_assistant-0.1.
|
|
27
|
-
jarvis_ai_assistant-0.1.
|
|
28
|
-
jarvis_ai_assistant-0.1.
|
|
29
|
-
jarvis_ai_assistant-0.1.
|
|
24
|
+
jarvis_ai_assistant-0.1.61.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
25
|
+
jarvis_ai_assistant-0.1.61.dist-info/METADATA,sha256=GAXcRDc-6S5k0wEoSdTkD-n-_RcFGcnjqTnabBDPjow,11213
|
|
26
|
+
jarvis_ai_assistant-0.1.61.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
27
|
+
jarvis_ai_assistant-0.1.61.dist-info/entry_points.txt,sha256=ieRI4ilnGNx1R6LlzT2P510mJ27lhLesVZToezDjSd8,89
|
|
28
|
+
jarvis_ai_assistant-0.1.61.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
29
|
+
jarvis_ai_assistant-0.1.61.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.59.dist-info → jarvis_ai_assistant-0.1.61.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|