jarvis-ai-assistant 0.1.62__py3-none-any.whl → 0.1.64__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 CHANGED
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.62"
3
+ __version__ = "0.1.64"
jarvis/agent.py CHANGED
@@ -142,28 +142,6 @@ class Agent:
142
142
  except Exception as e:
143
143
  PrettyOutput.print(f"总结对话历史失败: {str(e)}", OutputType.ERROR)
144
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
-
167
145
  def _complete_task(self) -> str:
168
146
  """完成任务并生成总结
169
147
 
@@ -171,8 +149,34 @@ class Agent:
171
149
  str: 任务总结或完成状态
172
150
  """
173
151
  PrettyOutput.section("任务完成", OutputType.SUCCESS)
174
-
175
- self._make_mathodology()
152
+
153
+ # 询问是否生成方法论,带输入验证
154
+ while True:
155
+ user_input = input("是否要为此任务生成方法论?(y/n): ").strip().lower()
156
+ if user_input in ['y', 'n', '']:
157
+ break
158
+ PrettyOutput.print("无效输入,请输入 y 或 n", OutputType.WARNING)
159
+
160
+ if user_input == 'y':
161
+ try:
162
+ # 让模型判断是否需要生成方法论
163
+ analysis_prompt = """本次任务已结束,请分析是否需要生成方法论。
164
+ 如果认为需要生成方法论,请先判断是创建新的方法论还是更新已有方法论。如果是更新已有方法论,使用update,否则使用add。
165
+ 如果认为不需要生成方法论,请说明原因。
166
+ 仅输出方法论工具的调用指令,或者是不需要生成方法论的说明,除此之外不要输出任何内容。
167
+ """
168
+ self.prompt = analysis_prompt
169
+ response = self._call_model(self.prompt)
170
+
171
+ # 检查是否包含工具调用
172
+ try:
173
+ result = Agent.extract_tool_calls(response)
174
+ PrettyOutput.print(result, OutputType.RESULT)
175
+ except Exception as e:
176
+ PrettyOutput.print(f"处理方法论生成失败: {str(e)}", OutputType.ERROR)
177
+
178
+ except Exception as e:
179
+ PrettyOutput.print(f"生成方法论时发生错误: {str(e)}", OutputType.ERROR)
176
180
 
177
181
  if not self.is_sub_agent:
178
182
  return "Task completed"
@@ -208,9 +212,6 @@ class Agent:
208
212
 
209
213
  # 加载方法论
210
214
  methodology = self._load_methodology()
211
-
212
- methodology =self._choose_methodology(methodology, user_input)
213
-
214
215
  methodology_prompt = ""
215
216
  if methodology:
216
217
  methodology_prompt = f"""这是以往处理问题的标准方法论,如果当前任务与此类似,可参考:
@@ -281,7 +282,6 @@ arguments:
281
282
 
282
283
  特殊指令:
283
284
  1. !<<SUMMARIZE>>! - 当你发现对话历史过长可能导致token超限时,可以使用此指令总结当前对话要点并清空历史。使用方法:直接回复"!<<SUMMARIZE>>!"即可。
284
- 2. !<<FINISHED>>! - 当你确认任务已经完成时,使用此指令结束任务。使用方法:在回复中包含"!<<FINISHED>>!"即可。
285
285
 
286
286
  -------------------------------------------------------------
287
287
 
@@ -326,10 +326,6 @@ arguments:
326
326
  self.prompt = tool_result
327
327
  continue
328
328
 
329
- # 检查是否完成任务
330
- if "!<<FINISHED>>!" in current_response:
331
- return self._complete_task()
332
-
333
329
  # 获取用户输入
334
330
  user_input = get_multiline_input(f"{self.name}: 您可以继续输入,或输入空行结束当前任务")
335
331
  if user_input == "__interrupt__":
@@ -8,7 +8,7 @@ class MethodologyTool:
8
8
  """经验管理工具"""
9
9
 
10
10
  name = "methodology"
11
- description = "管理问题处理经验总结,支持添加、更新、删除操作"
11
+ description = "管理问题处理方法论,支持添加、更新、删除操作"
12
12
  parameters = {
13
13
  "type": "object",
14
14
  "properties": {
@@ -23,7 +23,7 @@ class MethodologyTool:
23
23
  },
24
24
  "content": {
25
25
  "type": "string",
26
- "description": "经验总结内容 (update/add 时必需)",
26
+ "description": "方法论内容 (update/add 时必需)",
27
27
  "optional": True
28
28
  }
29
29
  },
@@ -36,39 +36,39 @@ class MethodologyTool:
36
36
  self._ensure_file_exists()
37
37
 
38
38
  def _ensure_file_exists(self):
39
- """确保经验总结文件存在"""
39
+ """确保方法论文件存在"""
40
40
  if not os.path.exists(self.methodology_file):
41
41
  try:
42
42
  with open(self.methodology_file, 'w', encoding='utf-8') as f:
43
43
  yaml.safe_dump({}, f, allow_unicode=True)
44
44
  except Exception as e:
45
- PrettyOutput.print(f"创建经验总结文件失败: {str(e)}", OutputType.ERROR)
45
+ PrettyOutput.print(f"创建方法论文件失败: {str(e)}", OutputType.ERROR)
46
46
 
47
47
  def _load_methodologies(self) -> Dict:
48
- """加载所有经验总结"""
48
+ """加载所有方法论"""
49
49
  try:
50
50
  with open(self.methodology_file, 'r', encoding='utf-8') as f:
51
51
  return yaml.safe_load(f) or {}
52
52
  except Exception as e:
53
- PrettyOutput.print(f"加载经验总结失败: {str(e)}", OutputType.ERROR)
53
+ PrettyOutput.print(f"加载方法论失败: {str(e)}", OutputType.ERROR)
54
54
  return {}
55
55
 
56
56
  def _save_methodologies(self, methodologies: Dict):
57
- """保存所有经验总结"""
57
+ """保存所有方法论"""
58
58
  try:
59
59
  with open(self.methodology_file, 'w', encoding='utf-8') as f:
60
60
  yaml.safe_dump(methodologies, f, allow_unicode=True)
61
61
  except Exception as e:
62
- PrettyOutput.print(f"保存经验总结失败: {str(e)}", OutputType.ERROR)
62
+ PrettyOutput.print(f"保存方法论失败: {str(e)}", OutputType.ERROR)
63
63
 
64
64
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
65
- """执行经验总结管理操作
65
+ """执行方法论管理操作
66
66
 
67
67
  Args:
68
68
  args: 包含操作参数的字典
69
69
  - operation: 操作类型 (delete/update/add)
70
70
  - problem_type: 问题类型
71
- - content: 经验总结内容 (update/add 时必需)
71
+ - content: 方法论内容 (update/add 时必需)
72
72
 
73
73
  Returns:
74
74
  Dict[str, Any]: 包含执行结果的字典
@@ -92,19 +92,19 @@ class MethodologyTool:
92
92
  self._save_methodologies(methodologies)
93
93
  return {
94
94
  "success": True,
95
- "stdout": f"已删除问题类型 '{problem_type}' 的经验总结"
95
+ "stdout": f"已删除问题类型 '{problem_type}' 的方法论"
96
96
  }
97
97
  else:
98
98
  return {
99
99
  "success": False,
100
- "error": f"未找到问题类型 '{problem_type}' 的经验总结"
100
+ "error": f"未找到问题类型 '{problem_type}' 的方法论"
101
101
  }
102
102
 
103
103
  elif operation in ["update", "add"]:
104
104
  if not content:
105
105
  return {
106
106
  "success": False,
107
- "error": "需要提供经验总结内容"
107
+ "error": "需要提供方法论内容"
108
108
  }
109
109
 
110
110
  methodologies[problem_type] = content
@@ -113,7 +113,7 @@ class MethodologyTool:
113
113
  action = "更新" if problem_type in methodologies else "添加"
114
114
  return {
115
115
  "success": True,
116
- "stdout": f"已{action}问题类型 '{problem_type}' 的经验总结"
116
+ "stdout": f"已{action}问题类型 '{problem_type}' 的方法论"
117
117
  }
118
118
 
119
119
  else:
@@ -129,13 +129,13 @@ class MethodologyTool:
129
129
  }
130
130
 
131
131
  def get_methodology(self, problem_type: str) -> Optional[str]:
132
- """获取指定问题类型的经验总结
132
+ """获取指定问题类型的方法论
133
133
 
134
134
  Args:
135
135
  problem_type: 问题类型
136
136
 
137
137
  Returns:
138
- Optional[str]: 经验总结内容,如果不存在则返回 None
138
+ Optional[str]: 方法论内容,如果不存在则返回 None
139
139
  """
140
140
  methodologies = self._load_methodologies()
141
141
  return methodologies.get(problem_type)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.62
3
+ Version: 0.1.64
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
@@ -1,5 +1,5 @@
1
- jarvis/__init__.py,sha256=7MU97ei05YsBW7t5VqUHERUT4Js54yZTst8gMIKPgNw,50
2
- jarvis/agent.py,sha256=rL3QMLD-48KMrRmiq8eU9T4ftdJdYVLg48e7df5Mg4E,14660
1
+ jarvis/__init__.py,sha256=wMtxQxTakpumAd-K51g16_sMIW8so_8Pv15IEYnhfwI,50
2
+ jarvis/agent.py,sha256=kl6pwNrluzb-9eZKgwmsk5Jh4CpWi4F8B3RvEQNvc5U,14921
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
@@ -15,15 +15,15 @@ jarvis/tools/base.py,sha256=EGRGbdfbLXDLwtyoWdvp9rlxNX7bzc20t0Vc2VkwIEY,652
15
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
- jarvis/tools/methodology.py,sha256=G3cOaHTMujGZBhDLhQEqyCV2NISizO3MXRuho1KfI6Y,5223
18
+ jarvis/tools/methodology.py,sha256=UG6s5VYRcd9wrKX4cg6f7zJhet5AIcthFGMOAdevBiw,5175
19
19
  jarvis/tools/registry.py,sha256=mlOAmUq3yzRz-7yvwrrCwbe5Lmw8eh1v8-_Fa5sezwI,7209
20
20
  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.62.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
25
- jarvis_ai_assistant-0.1.62.dist-info/METADATA,sha256=_Cqkqht2HfcYJEVA8BTLmjN0pDQHrYKkWne_fhH-9Ds,11213
26
- jarvis_ai_assistant-0.1.62.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
27
- jarvis_ai_assistant-0.1.62.dist-info/entry_points.txt,sha256=ieRI4ilnGNx1R6LlzT2P510mJ27lhLesVZToezDjSd8,89
28
- jarvis_ai_assistant-0.1.62.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
29
- jarvis_ai_assistant-0.1.62.dist-info/RECORD,,
24
+ jarvis_ai_assistant-0.1.64.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
25
+ jarvis_ai_assistant-0.1.64.dist-info/METADATA,sha256=akHo9a0miOBYWvtITaAuo1G3PZxiE2yPSZxuh0QE1C4,11213
26
+ jarvis_ai_assistant-0.1.64.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
27
+ jarvis_ai_assistant-0.1.64.dist-info/entry_points.txt,sha256=ieRI4ilnGNx1R6LlzT2P510mJ27lhLesVZToezDjSd8,89
28
+ jarvis_ai_assistant-0.1.64.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
29
+ jarvis_ai_assistant-0.1.64.dist-info/RECORD,,