jarvis-ai-assistant 0.1.207__py3-none-any.whl → 0.1.208__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +71 -61
- jarvis/jarvis_agent/edit_file_handler.py +42 -46
- jarvis/jarvis_agent/jarvis.py +33 -39
- jarvis/jarvis_code_agent/code_agent.py +26 -27
- jarvis/jarvis_code_agent/lint.py +5 -5
- jarvis/jarvis_code_analysis/code_review.py +164 -175
- jarvis/jarvis_git_utils/git_commiter.py +147 -152
- jarvis/jarvis_methodology/main.py +70 -81
- jarvis/jarvis_platform/base.py +21 -17
- jarvis/jarvis_platform/kimi.py +39 -53
- jarvis/jarvis_platform/tongyi.py +108 -126
- jarvis/jarvis_platform/yuanbao.py +112 -120
- jarvis/jarvis_platform_manager/main.py +102 -502
- jarvis/jarvis_platform_manager/service.py +432 -0
- jarvis/jarvis_smart_shell/main.py +99 -33
- jarvis/jarvis_tools/edit_file.py +64 -55
- jarvis/jarvis_tools/file_analyzer.py +17 -25
- jarvis/jarvis_tools/read_code.py +80 -81
- jarvis/jarvis_utils/builtin_replace_map.py +1 -36
- jarvis/jarvis_utils/config.py +14 -4
- jarvis/jarvis_utils/git_utils.py +36 -35
- jarvis/jarvis_utils/methodology.py +12 -17
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/METADATA +1 -10
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/RECORD +29 -34
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/entry_points.txt +0 -1
- jarvis/jarvis_dev/main.py +0 -1247
- jarvis/jarvis_tools/chdir.py +0 -72
- jarvis/jarvis_tools/code_plan.py +0 -218
- jarvis/jarvis_tools/create_code_agent.py +0 -95
- jarvis/jarvis_tools/create_sub_agent.py +0 -82
- jarvis/jarvis_tools/file_operation.py +0 -238
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/top_level.txt +0 -0
@@ -7,11 +7,8 @@ import time
|
|
7
7
|
import urllib.parse
|
8
8
|
from typing import Dict, Generator, List, Tuple
|
9
9
|
|
10
|
-
import requests
|
11
|
-
from PIL import Image
|
12
|
-
from yaspin import yaspin
|
13
|
-
from yaspin.api import Yaspin
|
14
|
-
from yaspin.spinners import Spinners
|
10
|
+
import requests # type: ignore
|
11
|
+
from PIL import Image # type: ignore
|
15
12
|
|
16
13
|
from jarvis.jarvis_platform.base import BasePlatform
|
17
14
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
@@ -98,7 +95,8 @@ class YuanbaoPlatform(BasePlatform):
|
|
98
95
|
|
99
96
|
try:
|
100
97
|
response = while_success(
|
101
|
-
lambda: requests.post(url, headers=headers, data=payload, timeout=600),
|
98
|
+
lambda: requests.post(url, headers=headers, data=payload, timeout=600),
|
99
|
+
sleep_time=5,
|
102
100
|
)
|
103
101
|
response_json = response.json()
|
104
102
|
|
@@ -135,115 +133,107 @@ class YuanbaoPlatform(BasePlatform):
|
|
135
133
|
|
136
134
|
for file_path in file_list:
|
137
135
|
file_name = os.path.basename(file_path)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
)
|
209
|
-
if not upload_success:
|
210
|
-
spinner.text = f"上传文件 {file_name} 失败"
|
211
|
-
spinner.fail("❌")
|
212
|
-
return False
|
213
|
-
|
214
|
-
# 4. Create file metadata for chat
|
215
|
-
spinner.text = f"生成文件元数据: {file_name}"
|
216
|
-
file_metadata = {
|
217
|
-
"type": file_type,
|
218
|
-
"docType": file_extension if file_extension else file_type,
|
219
|
-
"url": upload_info.get("resourceUrl", ""),
|
220
|
-
"fileName": file_name,
|
221
|
-
"size": file_size,
|
222
|
-
"width": 0,
|
223
|
-
"height": 0,
|
224
|
-
}
|
225
|
-
|
226
|
-
# Get image dimensions if it's an image file
|
227
|
-
if file_type == "image":
|
228
|
-
try:
|
229
|
-
with Image.open(file_path) as img:
|
230
|
-
file_metadata["width"] = img.width
|
231
|
-
file_metadata["height"] = img.height
|
232
|
-
except Exception as e:
|
233
|
-
spinner.write(
|
234
|
-
f"⚠️ 无法获取图片 {file_name} 的尺寸: {str(e)}"
|
235
|
-
)
|
236
|
-
|
237
|
-
uploaded_files.append(file_metadata)
|
238
|
-
spinner.text = f"文件 {file_name} 上传成功"
|
239
|
-
spinner.ok("✅")
|
240
|
-
time.sleep(3) # 上传成功后等待3秒
|
241
|
-
|
242
|
-
except Exception as e:
|
243
|
-
spinner.text = f"上传文件 {file_path} 时出错: {str(e)}"
|
244
|
-
spinner.fail("❌")
|
136
|
+
print(f"🔍 上传文件 {file_name}")
|
137
|
+
try:
|
138
|
+
|
139
|
+
# 1. Prepare the file information
|
140
|
+
print(f"🔍 准备文件信息: {file_name}")
|
141
|
+
file_size = os.path.getsize(file_path)
|
142
|
+
file_extension = os.path.splitext(file_path)[1].lower().lstrip(".")
|
143
|
+
|
144
|
+
# Determine file_type using file extension
|
145
|
+
file_type = "txt" # Default type
|
146
|
+
|
147
|
+
# Image types
|
148
|
+
if file_extension in ["jpg", "jpeg", "png", "webp", "bmp", "gif"]:
|
149
|
+
file_type = "image"
|
150
|
+
# PDF type
|
151
|
+
elif file_extension == "pdf":
|
152
|
+
file_type = "pdf"
|
153
|
+
# Spreadsheet types
|
154
|
+
elif file_extension in ["xls", "xlsx"]:
|
155
|
+
file_type = "excel"
|
156
|
+
# Presentation types
|
157
|
+
elif file_extension in ["ppt", "pptx"]:
|
158
|
+
file_type = "ppt"
|
159
|
+
# Document types
|
160
|
+
elif file_extension in ["doc", "docx"]:
|
161
|
+
file_type = "doc"
|
162
|
+
# Code file types
|
163
|
+
elif file_extension in [
|
164
|
+
"bat",
|
165
|
+
"c",
|
166
|
+
"cpp",
|
167
|
+
"cs",
|
168
|
+
"css",
|
169
|
+
"go",
|
170
|
+
"h",
|
171
|
+
"hpp",
|
172
|
+
"ini",
|
173
|
+
"java",
|
174
|
+
"js",
|
175
|
+
"json",
|
176
|
+
"log",
|
177
|
+
"lua",
|
178
|
+
"php",
|
179
|
+
"pl",
|
180
|
+
"py",
|
181
|
+
"rb",
|
182
|
+
"sh",
|
183
|
+
"sql",
|
184
|
+
"swift",
|
185
|
+
"tex",
|
186
|
+
"toml",
|
187
|
+
"vue",
|
188
|
+
"yaml",
|
189
|
+
"yml",
|
190
|
+
"rs",
|
191
|
+
]:
|
192
|
+
file_type = "code"
|
193
|
+
|
194
|
+
# 2. Generate upload information
|
195
|
+
print(f"🔍 获取上传信息: {file_name}")
|
196
|
+
upload_info = self._generate_upload_info(file_name)
|
197
|
+
if not upload_info:
|
198
|
+
print(f"❌ 无法获取文件 {file_name} 的上传信息")
|
199
|
+
return False
|
200
|
+
|
201
|
+
# 3. Upload the file to COS
|
202
|
+
print(f"🔍 上传文件到云存储: {file_name}")
|
203
|
+
upload_success = self._upload_file_to_cos(file_path, upload_info)
|
204
|
+
if not upload_success:
|
205
|
+
print(f"❌ 上传文件 {file_name} 失败")
|
245
206
|
return False
|
246
207
|
|
208
|
+
# 4. Create file metadata for chat
|
209
|
+
print(f"🔍 生成文件元数据: {file_name}")
|
210
|
+
file_metadata = {
|
211
|
+
"type": file_type,
|
212
|
+
"docType": file_extension if file_extension else file_type,
|
213
|
+
"url": upload_info.get("resourceUrl", ""),
|
214
|
+
"fileName": file_name,
|
215
|
+
"size": file_size,
|
216
|
+
"width": 0,
|
217
|
+
"height": 0,
|
218
|
+
}
|
219
|
+
|
220
|
+
# Get image dimensions if it's an image file
|
221
|
+
if file_type == "image":
|
222
|
+
try:
|
223
|
+
with Image.open(file_path) as img:
|
224
|
+
file_metadata["width"] = img.width
|
225
|
+
file_metadata["height"] = img.height
|
226
|
+
except Exception as e:
|
227
|
+
print(f"⚠️ 无法获取图片 {file_name} 的尺寸: {str(e)}")
|
228
|
+
|
229
|
+
uploaded_files.append(file_metadata)
|
230
|
+
print(f"✅ 文件 {file_name} 上传成功")
|
231
|
+
time.sleep(3) # 上传成功后等待3秒
|
232
|
+
|
233
|
+
except Exception as e:
|
234
|
+
print(f"❌ 上传文件 {file_path} 时出错: {str(e)}")
|
235
|
+
return False
|
236
|
+
|
247
237
|
self.multimedia = uploaded_files
|
248
238
|
return True
|
249
239
|
|
@@ -264,7 +254,8 @@ class YuanbaoPlatform(BasePlatform):
|
|
264
254
|
|
265
255
|
try:
|
266
256
|
response = while_success(
|
267
|
-
lambda: requests.post(url, headers=headers, json=payload, timeout=600),
|
257
|
+
lambda: requests.post(url, headers=headers, json=payload, timeout=600),
|
258
|
+
sleep_time=5,
|
268
259
|
)
|
269
260
|
|
270
261
|
if response.status_code != 200:
|
@@ -283,9 +274,7 @@ class YuanbaoPlatform(BasePlatform):
|
|
283
274
|
PrettyOutput.print(f"获取上传信息时出错: {str(e)}", OutputType.ERROR)
|
284
275
|
return {}
|
285
276
|
|
286
|
-
def _upload_file_to_cos(
|
287
|
-
self, file_path: str, upload_info: Dict, spinner: Yaspin
|
288
|
-
) -> bool:
|
277
|
+
def _upload_file_to_cos(self, file_path: str, upload_info: Dict) -> bool:
|
289
278
|
"""使用提供的上传信息将文件上传到腾讯COS
|
290
279
|
|
291
280
|
参数:
|
@@ -313,7 +302,7 @@ class YuanbaoPlatform(BasePlatform):
|
|
313
302
|
with open(file_path, "rb") as file:
|
314
303
|
file_content = file.read()
|
315
304
|
|
316
|
-
|
305
|
+
print(f"ℹ️ 上传文件大小: {len(file_content)}")
|
317
306
|
|
318
307
|
# Prepare headers for PUT request
|
319
308
|
host = f"{upload_info['bucketName']}.{upload_info.get('accelerateDomain', 'cos.accelerate.myqcloud.com')}"
|
@@ -481,7 +470,9 @@ class YuanbaoPlatform(BasePlatform):
|
|
481
470
|
try:
|
482
471
|
# 发送消息请求,获取流式响应
|
483
472
|
response = while_success(
|
484
|
-
lambda: requests.post(
|
473
|
+
lambda: requests.post(
|
474
|
+
url, headers=headers, json=payload, stream=True, timeout=600
|
475
|
+
),
|
485
476
|
sleep_time=5,
|
486
477
|
)
|
487
478
|
|
@@ -556,7 +547,8 @@ class YuanbaoPlatform(BasePlatform):
|
|
556
547
|
|
557
548
|
try:
|
558
549
|
response = while_success(
|
559
|
-
lambda: requests.post(url, headers=headers, json=payload, timeout=600),
|
550
|
+
lambda: requests.post(url, headers=headers, json=payload, timeout=600),
|
551
|
+
sleep_time=5,
|
560
552
|
)
|
561
553
|
|
562
554
|
if response.status_code == 200:
|