jarvis-ai-assistant 0.1.14__py3-none-any.whl → 0.1.16__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.14"
3
+ __version__ = "0.1.16"
Binary file
Binary file
jarvis/agent.py CHANGED
@@ -87,21 +87,22 @@ class Agent:
87
87
  Returns:
88
88
  str: 任务总结报告
89
89
  """
90
- self.clear_history()
91
-
92
- if file_list:
93
- self.model.upload_files(file_list)
94
-
95
- # 显示任务开始
96
- PrettyOutput.section(f"开始新任务: {self.name}", OutputType.PLANNING)
90
+ try:
91
+ self.clear_history()
92
+
93
+ if file_list:
94
+ self.model.upload_files(file_list)
95
+
96
+ # 显示任务开始
97
+ PrettyOutput.section(f"开始新任务: {self.name}", OutputType.PLANNING)
97
98
 
98
- tools_prompt = "可用工具:\n"
99
- for tool in self.tool_registry.get_all_tools():
100
- tools_prompt += f"- 名称: {tool['name']}\n"
101
- tools_prompt += f" 描述: {tool['description']}\n"
102
- tools_prompt += f" 参数: {tool['parameters']}\n"
99
+ tools_prompt = "可用工具:\n"
100
+ for tool in self.tool_registry.get_all_tools():
101
+ tools_prompt += f"- 名称: {tool['name']}\n"
102
+ tools_prompt += f" 描述: {tool['description']}\n"
103
+ tools_prompt += f" 参数: {tool['parameters']}\n"
103
104
 
104
- self.prompt =f"""你是 {self.name},一个严格遵循 ReAct 框架进行逐步推理和行动的 AI 助手。
105
+ self.prompt = f"""你是 {self.name},一个严格遵循 ReAct 框架进行逐步推理和行动的 AI 助手。
105
106
 
106
107
  {tools_prompt}
107
108
 
@@ -194,53 +195,61 @@ arguments:
194
195
  任务:
195
196
  {user_input}
196
197
  """
197
-
198
-
199
- while True:
200
- try:
201
- # 显示思考状态
202
- PrettyOutput.print("分析任务...", OutputType.PROGRESS)
203
-
204
- current_response = self._call_model(self.prompt)
205
198
 
199
+ while True:
206
200
  try:
207
- result = Agent.extract_tool_calls(current_response)
208
- except Exception as e:
209
- PrettyOutput.print(f"工具调用错误: {str(e)}", OutputType.ERROR)
210
- self.prompt = f"工具调用错误: {str(e)}"
211
- continue
212
-
213
- if len(result) > 0:
201
+ # 显示思考状态
202
+ PrettyOutput.print("分析任务...", OutputType.PROGRESS)
203
+
204
+ current_response = self._call_model(self.prompt)
205
+
214
206
  try:
215
- # 显示工具调用
216
- PrettyOutput.print("执行工具调用...", OutputType.PROGRESS)
217
- tool_result = self.tool_registry.handle_tool_calls(result)
218
- PrettyOutput.print(tool_result, OutputType.RESULT)
207
+ result = Agent.extract_tool_calls(current_response)
219
208
  except Exception as e:
220
- PrettyOutput.print(str(e), OutputType.ERROR)
221
- tool_result = f"Tool call failed: {str(e)}"
222
-
223
- self.prompt = tool_result
224
- continue
225
-
226
- # 获取用户输入
227
- user_input = get_multiline_input(f"{self.name}: 您可以继续输入,或输入空行结束当前任务")
228
- if user_input == "__interrupt__":
229
- PrettyOutput.print("任务已取消", OutputType.WARNING)
230
- return "Task cancelled by user"
231
- if user_input:
232
- self.prompt = user_input
233
- continue
234
-
235
- if not user_input:
209
+ PrettyOutput.print(f"工具调用错误: {str(e)}", OutputType.ERROR)
210
+ self.prompt = f"工具调用错误: {str(e)}"
211
+ continue
212
+
213
+ if len(result) > 0:
214
+ try:
215
+ # 显示工具调用
216
+ PrettyOutput.print("执行工具调用...", OutputType.PROGRESS)
217
+ tool_result = self.tool_registry.handle_tool_calls(result)
218
+ PrettyOutput.print(tool_result, OutputType.RESULT)
219
+ except Exception as e:
220
+ PrettyOutput.print(str(e), OutputType.ERROR)
221
+ tool_result = f"Tool call failed: {str(e)}"
222
+
223
+ self.prompt = tool_result
224
+ continue
225
+
226
+ # 获取用户输入
227
+ user_input = get_multiline_input(f"{self.name}: 您可以继续输入,或输入空行结束当前任务")
228
+ if user_input == "__interrupt__":
229
+ PrettyOutput.print("任务已取消", OutputType.WARNING)
230
+ return "Task cancelled by user"
231
+ if user_input:
232
+ self.prompt = user_input
233
+ continue
234
+
235
+ if not user_input:
236
236
  PrettyOutput.section("任务完成", OutputType.SUCCESS)
237
237
  return
238
-
239
238
 
240
-
241
-
239
+ except Exception as e:
240
+ PrettyOutput.print(str(e), OutputType.ERROR)
241
+ return f"Task failed: {str(e)}"
242
+
243
+ except Exception as e:
244
+ PrettyOutput.print(str(e), OutputType.ERROR)
245
+ return f"Task failed: {str(e)}"
246
+
247
+ finally:
248
+ # 确保在所有情况下都删除会话
249
+ try:
250
+ self.model.delete_chat()
242
251
  except Exception as e:
243
- PrettyOutput.print(str(e), OutputType.ERROR)
252
+ PrettyOutput.print(f"清理会话时发生错误: {str(e)}", OutputType.ERROR)
244
253
 
245
254
  def clear_history(self):
246
255
  """清除对话历史,只保留系统提示"""
jarvis/models/kimi.py CHANGED
@@ -246,8 +246,34 @@ class KimiModel(BaseModel):
246
246
  except Exception as e:
247
247
  raise Exception(f"Chat failed: {str(e)}")
248
248
 
249
+ def delete_chat(self) -> bool:
250
+ """删除当前会话"""
251
+ if not self.chat_id:
252
+ return True # 如果没有会话ID,视为删除成功
253
+
254
+ url = f"https://kimi.moonshot.cn/api/chat/{self.chat_id}"
255
+ headers = {
256
+ 'Authorization': self.auth_header,
257
+ 'Content-Type': 'application/json'
258
+ }
259
+
260
+ try:
261
+ response = requests.delete(url, headers=headers)
262
+ if response.status_code == 200:
263
+ PrettyOutput.print("会话已删除", OutputType.SUCCESS)
264
+ self.chat_id = "" # 清除会话ID
265
+ return True
266
+ else:
267
+ PrettyOutput.print(f"删除会话失败: HTTP {response.status_code}", OutputType.ERROR)
268
+ return False
269
+ except Exception as e:
270
+ PrettyOutput.print(f"删除会话时发生错误: {str(e)}", OutputType.ERROR)
271
+ return False
272
+
249
273
  def reset(self):
250
274
  """重置对话"""
275
+ if self.chat_id:
276
+ self.delete_chat() # 删除现有会话
251
277
  self.chat_id = ""
252
278
  self.uploaded_files = []
253
279
  self.first_chat = True # 重置first_chat标记
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 skyfire
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,10 +1,31 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.14
3
+ Version: 0.1.16
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
7
7
  Author-email: Your Name <your.email@example.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 skyfire
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
8
29
  Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
9
30
  Keywords: jarvis,ai,assistant,tools,automation
10
31
  Classifier: License :: OSI Approved :: MIT License
@@ -16,6 +37,7 @@ Classifier: Programming Language :: Python :: 3.10
16
37
  Classifier: Programming Language :: Python :: 3.11
17
38
  Requires-Python: >=3.8
18
39
  Description-Content-Type: text/markdown
40
+ License-File: LICENSE
19
41
  Requires-Dist: requests>=2.25.1
20
42
  Requires-Dist: pyyaml>=5.1
21
43
  Requires-Dist: colorama>=0.4.6
@@ -1,9 +1,9 @@
1
- jarvis/__init__.py,sha256=ASmWOyubd5yF30GOCGKZ5qOTjVIoSmQ4eOT7ImnQHpw,50
2
- jarvis/agent.py,sha256=xo5YdY8UbgE3AJaitT1dXoNoVm769LrWyFzEXxVCG7A,8672
1
+ jarvis/__init__.py,sha256=IrFrXtY58xy8OQAUNGadwY5YeK6GgT8xcnXUEb2EWb8,50
2
+ jarvis/agent.py,sha256=sa8un7OmbGRlSAD4V-Be0Y9-TCT-S_0OFFthEBXWdVs,9267
3
3
  jarvis/main.py,sha256=QD8FlhpJ-PFUEOjt77gllpHEgqtfNKV_S8NQZSWRTbE,6760
4
4
  jarvis/utils.py,sha256=YipQpEuIRwFE3y3YrgGlSVLEPDrlbBNY1gRiOJix9DU,6602
5
- jarvis/__pycache__/__init__.cpython-313.pyc,sha256=LOM8mV9fUUpfEt-eCawXu9EW44gzfiAAUY7tOmgtjBM,209
6
- jarvis/__pycache__/agent.cpython-313.pyc,sha256=DP0zgyKjGuwc62rH_vpoy_hXmGMI3zoHPlXZYu0qqp4,9956
5
+ jarvis/__pycache__/__init__.cpython-313.pyc,sha256=P5b0eXfExQu7lDPOOOphvz7WiD2NJHJfsRVoYfDdTbw,209
6
+ jarvis/__pycache__/agent.cpython-313.pyc,sha256=rrAZtJSYuJZcTL8gdF0S7XdaNQxpMA8BnNrSoLAny_Q,11913
7
7
  jarvis/__pycache__/main.cpython-313.pyc,sha256=vsL4l0JZFp805S22a0uZR_9k6NhpHrb-YHFY61JXF4M,9279
8
8
  jarvis/__pycache__/models.cpython-313.pyc,sha256=uWuRIjGrY4YDB3dGW5PGDLWaS03et8g11O725TjY_eU,5960
9
9
  jarvis/__pycache__/tools.cpython-313.pyc,sha256=lAD4LrnnWzNZQmHXGfZ_2l7oskOpr2_2OC-gdFhxQY8,33933
@@ -11,10 +11,10 @@ jarvis/__pycache__/utils.cpython-313.pyc,sha256=Jpkf2GOA1d_fgrRftqZch1yiO0mB75LW
11
11
  jarvis/__pycache__/zte_llm.cpython-313.pyc,sha256=kMm9IGundGmOPqjsgrm9oIaWLDagYGCPRAaE3ipkc-0,5662
12
12
  jarvis/models/__init__.py,sha256=B_IJFvKTaxdg19FAD1ea288tYp3-bRYRpkeGI0_OcBI,262
13
13
  jarvis/models/base.py,sha256=GgVl5N0qDqn-yqRcX_PX3wHjogouE6GPFAWktG40cXg,403
14
- jarvis/models/kimi.py,sha256=J_0QB6XY61tY-Oeu2cexWto58QbMU_liYj1f6PKbNRw,9763
14
+ jarvis/models/kimi.py,sha256=YzMLC6_grynNVdPzBBmluFHvcDGdikwxMq7Tl7c6JLA,10791
15
15
  jarvis/models/__pycache__/__init__.cpython-313.pyc,sha256=jAwySX4diR7EWM_alK75tiIb_J8bVfs4Bh_U3bdjDLo,534
16
16
  jarvis/models/__pycache__/base.cpython-313.pyc,sha256=4I9KZlXHvTB7vENA9YWK4Fx0sns_KvIOtWqzE9y_-Co,1094
17
- jarvis/models/__pycache__/kimi.cpython-313.pyc,sha256=ks1WiR1d8NTu-0B4s9zIyifWUvijBN4qI6AFD0Jtgk0,12524
17
+ jarvis/models/__pycache__/kimi.cpython-313.pyc,sha256=RZIfeTDZgvJX7GyEZJ1NT_22WQJ2CyK5xR8RZ-L6WBQ,13717
18
18
  jarvis/tools/__init__.py,sha256=000SvX1Z0yzKtuVR9NS45r41DHUVpE6EiSEzzE99uR0,196
19
19
  jarvis/tools/base.py,sha256=qm73kMOkqAWHjUisUWFye-x69LJuZdwm0U3Tct-mmMc,3890
20
20
  jarvis/tools/file_ops.py,sha256=zTksx45NZm3iz9itN5iQGZ8DoxnSeTHdrnF08_ix7PU,3770
@@ -32,8 +32,9 @@ jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc,sha256=wK3Ev10lHSUSRv
32
32
  jarvis/tools/__pycache__/user_input.cpython-313.pyc,sha256=JjTFOhObKsKF4Pn8KBRuKfV1_Ssj083fjU7Mfc_5z7c,2531
33
33
  jarvis/tools/__pycache__/user_interaction.cpython-313.pyc,sha256=RuVZ-pmiPBDywY3efgXSfohMAciC1avMGPmBK5qlnew,3305
34
34
  jarvis/tools/__pycache__/webpage.cpython-313.pyc,sha256=BjzSfnNzsKCrLETCcWjt32lNDLzwnjqcVGg4JfWd9OM,3008
35
- jarvis_ai_assistant-0.1.14.dist-info/METADATA,sha256=c9CfamgEPsk1HeSU6wx7onzQ7rWerFpOkh1Jz7IgkYU,5270
36
- jarvis_ai_assistant-0.1.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
37
- jarvis_ai_assistant-0.1.14.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
38
- jarvis_ai_assistant-0.1.14.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
39
- jarvis_ai_assistant-0.1.14.dist-info/RECORD,,
35
+ jarvis_ai_assistant-0.1.16.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
36
+ jarvis_ai_assistant-0.1.16.dist-info/METADATA,sha256=MM6V4lp04d0vFDoNIhU6NqFpi8zgXBsMXlX5wAHrJII,6525
37
+ jarvis_ai_assistant-0.1.16.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
38
+ jarvis_ai_assistant-0.1.16.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
39
+ jarvis_ai_assistant-0.1.16.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
40
+ jarvis_ai_assistant-0.1.16.dist-info/RECORD,,