jarvis-ai-assistant 0.1.25__tar.gz → 0.1.27__tar.gz

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.

Files changed (53) hide show
  1. {jarvis_ai_assistant-0.1.25/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.27}/PKG-INFO +1 -1
  2. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/pyproject.toml +1 -1
  3. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/setup.py +1 -1
  4. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__init__.py +1 -1
  5. jarvis_ai_assistant-0.1.27/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  6. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  7. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/agent.py +18 -60
  8. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/__pycache__/kimi.cpython-313.pyc +0 -0
  9. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/kimi.py +20 -11
  10. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
  11. jarvis_ai_assistant-0.1.25/src/jarvis/__pycache__/__init__.cpython-313.pyc +0 -0
  12. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/LICENSE +0 -0
  13. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/MANIFEST.in +0 -0
  14. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/README.md +0 -0
  15. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/setup.cfg +0 -0
  16. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/main.cpython-313.pyc +0 -0
  17. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/models.cpython-313.pyc +0 -0
  18. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  19. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  20. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/__pycache__/zte_llm.cpython-313.pyc +0 -0
  21. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/main.py +0 -0
  22. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/__init__.py +0 -0
  23. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/__pycache__/__init__.cpython-313.pyc +0 -0
  24. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/__pycache__/base.cpython-313.pyc +0 -0
  25. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/models/base.py +0 -0
  26. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__init__.py +0 -0
  27. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  28. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  29. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/bing_search.cpython-313.pyc +0 -0
  30. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/calculator.cpython-313.pyc +0 -0
  31. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/calculator_tool.cpython-313.pyc +0 -0
  32. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  33. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/generator.cpython-313.pyc +0 -0
  34. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  35. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  36. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  37. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  38. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/sub_agent.cpython-313.pyc +0 -0
  39. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  40. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/user_input.cpython-313.pyc +0 -0
  41. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  42. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  43. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/base.py +0 -0
  44. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/file_ops.py +0 -0
  45. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/generator.py +0 -0
  46. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/shell.py +0 -0
  47. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/tools/sub_agent.py +0 -0
  48. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis/utils.py +0 -0
  49. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  50. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  51. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  52. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  53. {jarvis_ai_assistant-0.1.25 → jarvis_ai_assistant-0.1.27}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.25
3
+ Version: 0.1.27
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.25"
7
+ version = "0.1.27"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Your Name", email = "your.email@example.com" }]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="jarvis-ai-assistant",
5
- version="0.1.25",
5
+ version="0.1.27",
6
6
  author="skyfire",
7
7
  author_email="skyfireitdiy@hotmail.com",
8
8
  description="An AI assistant that uses various tools to interact with the system",
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.25"
3
+ __version__ = "0.1.27"
@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import subprocess
3
+ import time
3
4
  from typing import Dict, Any, List, Optional, Tuple
4
5
 
5
6
  import yaml
@@ -56,13 +57,13 @@ class Agent:
56
57
  }]
57
58
  else:
58
59
  PrettyOutput.print("工具调用缺少必要字段", OutputType.ERROR)
59
- raise '工具调用缺少必要字段'
60
+ raise Exception("工具调用缺少必要字段")
60
61
  except yaml.YAMLError as e:
61
62
  PrettyOutput.print(f"YAML解析错误: {str(e)}", OutputType.ERROR)
62
- raise 'YAML解析错误'
63
+ raise Exception(f"YAML解析错误: {str(e)}")
63
64
  except Exception as e:
64
65
  PrettyOutput.print(f"处理工具调用时发生错误: {str(e)}", OutputType.ERROR)
65
- raise '处理工具调用时发生错误'
66
+ raise Exception(f"处理工具调用时发生错误: {str(e)}")
66
67
  in_tool_call = False
67
68
  continue
68
69
 
@@ -74,7 +75,13 @@ class Agent:
74
75
  def _call_model(self, message: str) -> str:
75
76
  """调用模型获取响应"""
76
77
  try:
77
- return self.model.chat(message)
78
+ while True:
79
+ ret = self.model.chat(message)
80
+ if not ret:
81
+ PrettyOutput.print("模型返回空值,可能负载过重,5s后重试...", OutputType.WARNING)
82
+ time.sleep(5)
83
+ continue
84
+ return ret
78
85
  except Exception as e:
79
86
  raise Exception(f"{self.name}: 模型调用失败: {str(e)}")
80
87
 
@@ -110,24 +117,21 @@ class Agent:
110
117
 
111
118
  核心能力:
112
119
  1. 使用现有工具完成任务
113
- 2. 通过 generate_tool 创建新工具扩展功能
114
- 3. 通过 create_sub_agent 创建子代理处理独立任务
115
- 4. 访问和理解网页内容(无需使用工具)
120
+ 2. 访问和理解网页内容(无需使用工具)
116
121
  5. 遵循 ReAct (思考-行动-观察) 框架
117
122
 
118
123
  工作流程:
119
124
  1. 思考
120
125
  - 分析需求和可用工具
121
- - 评估是否需要新工具
122
- - 考虑是否需要拆分子任务
126
+ - 评估是否能用现有工具完成
127
+ - 考虑是否需要访问网页
123
128
  - 规划解决方案
124
- - 确定是否需要访问网页
125
129
 
126
130
  2. 行动 (如果需要)
127
- - 使用现有工具
128
- - 创建新工具
129
- - 创建子代理
131
+ - 优先使用现有工具
130
132
  - 访问网页获取信息
133
+ - 创建新工具(成本高,谨慎使用)
134
+ - 创建子代理(成本高,谨慎使用)
131
135
  - 询问更多信息
132
136
 
133
137
  3. 观察
@@ -135,58 +139,12 @@ class Agent:
135
139
  - 分析反馈
136
140
  - 规划下一步
137
141
 
138
- 网页访问能力:
139
- - 可以直接访问和阅读网页内容
140
- - 无需使用额外工具
141
- - 可以提取和分析网页信息
142
- - 支持多种网页格式
143
- - 注意:仅支持公开访问的网页
144
-
145
- 任务拆分建议:
146
- - 当任务包含多个独立步骤时
147
- - 当子任务需要独立的上下文时
148
- - 当子任务有明确的完成目标时
149
- - 当需要并行处理多个任务时
150
-
151
- 创建子代理时,必须提供尽可能多的上下文信息,以确保其正确工作。
152
-
153
- 创建子代理示例:
154
- <START_TOOL_CALL>
155
- name: create_sub_agent
156
- arguments:
157
- agent_name: CodeAnalyzer
158
- task: 分析项目代码质量
159
- context: |
160
- 这是一个Python项目
161
- 使用了Flask框架
162
- 需要关注性能和安全性
163
- goal: 生成代码质量分析报告
164
- <END_TOOL_CALL>
165
-
166
- 创建新工具示例:
167
- <START_TOOL_CALL>
168
- name: generate_tool
169
- arguments:
170
- tool_name: custom_tool_name
171
- class_name: CustomToolName
172
- description: 详细的工具描述
173
- parameters:
174
- type: object
175
- properties:
176
- param1:
177
- type: string
178
- description: 参数1的描述
179
- required: [param1]
180
- <END_TOOL_CALL>
181
-
182
142
  工具使用格式:
183
143
  <START_TOOL_CALL>
184
144
  name: tool_name
185
145
  arguments:
186
146
  param1: value1
187
- param2: |
188
- multiline
189
- value
147
+ param2: value2
190
148
  <END_TOOL_CALL>
191
149
 
192
150
  严格规则:
@@ -45,11 +45,11 @@ class KimiModel(BaseModel):
45
45
  PrettyOutput.print(f"Failed to create chat: {e}: Response: {response.text}", OutputType.ERROR)
46
46
  return False
47
47
 
48
- def _get_presigned_url(self, filename: str) -> Dict:
48
+ def _get_presigned_url(self, filename: str, action: str) -> Dict:
49
49
  """获取预签名上传URL"""
50
50
  url = "https://kimi.moonshot.cn/api/pre-sign-url"
51
- mime_type, _ = mimetypes.guess_type(filename)
52
- action = "image" if mime_type and mime_type.startswith('image/') else "file"
51
+
52
+
53
53
 
54
54
  payload = json.dumps({
55
55
  "action": action,
@@ -75,11 +75,11 @@ class KimiModel(BaseModel):
75
75
  PrettyOutput.print(f"Failed to upload file: {e}", OutputType.ERROR)
76
76
  return False
77
77
 
78
- def _get_file_info(self, file_data: Dict, name: str) -> Dict:
78
+ def _get_file_info(self, file_data: Dict, name: str, file_type: str) -> Dict:
79
79
  """获取文件信息"""
80
80
  url = "https://kimi.moonshot.cn/api/file"
81
81
  payload = json.dumps({
82
- "type": "file",
82
+ "type": file_type,
83
83
  "name": name,
84
84
  "object_name": file_data["object_name"],
85
85
  "chat_id": self.chat_id,
@@ -114,6 +114,7 @@ class KimiModel(BaseModel):
114
114
  continue
115
115
 
116
116
  line = line.decode('utf-8')
117
+ print(data)
117
118
  if not line.startswith("data: "):
118
119
  continue
119
120
 
@@ -149,25 +150,33 @@ class KimiModel(BaseModel):
149
150
  for index, file_path in enumerate(file_list, 1):
150
151
  try:
151
152
  PrettyOutput.print(f"处理文件 [{index}/{len(file_list)}]: {file_path}", OutputType.PROGRESS)
153
+
154
+ mime_type, _ = mimetypes.guess_type(file_path)
155
+ action = "image" if mime_type and mime_type.startswith('image/') else "file"
152
156
 
153
157
  # 获取预签名URL
154
158
  PrettyOutput.print("获取上传URL...", OutputType.PROGRESS)
155
- presigned_data = self._get_presigned_url(file_path)
159
+ presigned_data = self._get_presigned_url(file_path, action)
156
160
 
157
161
  # 上传文件
158
162
  PrettyOutput.print("上传文件内容...", OutputType.PROGRESS)
159
163
  if self._upload_file(file_path, presigned_data["url"]):
160
164
  # 获取文件信息
161
165
  PrettyOutput.print("获取文件信息...", OutputType.PROGRESS)
162
- file_info = self._get_file_info(presigned_data, os.path.basename(file_path))
163
-
166
+ file_info = self._get_file_info(presigned_data, os.path.basename(file_path), action)
164
167
  # 等待文件解析
165
168
  PrettyOutput.print("等待文件解析完成...", OutputType.PROGRESS)
166
- if self._wait_for_parse(file_info["id"]):
169
+
170
+ # 只有文件需要解析
171
+ if action == "file":
172
+ if self._wait_for_parse(file_info["id"]):
173
+ uploaded_files.append(file_info)
174
+ PrettyOutput.print(f"✓ 文件处理成功: {file_path}", OutputType.SUCCESS)
175
+ else:
176
+ PrettyOutput.print(f"✗ 文件解析失败: {file_path}", OutputType.ERROR)
177
+ else:
167
178
  uploaded_files.append(file_info)
168
179
  PrettyOutput.print(f"✓ 文件处理成功: {file_path}", OutputType.SUCCESS)
169
- else:
170
- PrettyOutput.print(f"✗ 文件解析失败: {file_path}", OutputType.ERROR)
171
180
  else:
172
181
  PrettyOutput.print(f"✗ 文件上传失败: {file_path}", OutputType.ERROR)
173
182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.25
3
+ Version: 0.1.27
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