jarvis-ai-assistant 0.1.206__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_data/config_schema.json +1 -1
- jarvis/jarvis_git_utils/git_commiter.py +147 -152
- jarvis/jarvis_methodology/main.py +70 -81
- jarvis/jarvis_platform/base.py +28 -23
- 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.206.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/METADATA +7 -16
- {jarvis_ai_assistant-0.1.206.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/RECORD +30 -35
- {jarvis_ai_assistant-0.1.206.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.206.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.206.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.206.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/top_level.txt +0 -0
jarvis/jarvis_platform/kimi.py
CHANGED
@@ -187,68 +187,54 @@ class KimiModel(BasePlatform):
|
|
187
187
|
if not file_list:
|
188
188
|
return True
|
189
189
|
|
190
|
-
from yaspin import yaspin # type: ignore
|
191
|
-
|
192
190
|
if not self.chat_id:
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
spinner.text = "创建聊天会话成功"
|
199
|
-
spinner.ok("✅")
|
191
|
+
print("🚀 正在创建聊天会话...")
|
192
|
+
if not self._create_chat():
|
193
|
+
print("❌ 创建聊天会话失败")
|
194
|
+
return False
|
195
|
+
print("✅ 创建聊天会话成功")
|
200
196
|
|
201
197
|
uploaded_files = []
|
202
198
|
for index, file_path in enumerate(file_list, 1):
|
203
199
|
file_name = os.path.basename(file_path)
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
mime_type
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
)
|
227
|
-
|
228
|
-
# 只有文件需要解析
|
229
|
-
if action == "file":
|
230
|
-
spinner.text = f"等待文件解析: {file_name}"
|
231
|
-
if self._wait_for_parse(file_info["id"]):
|
232
|
-
uploaded_files.append(file_info)
|
233
|
-
spinner.text = f"文件处理完成: {file_name}"
|
234
|
-
spinner.ok("✅")
|
235
|
-
else:
|
236
|
-
spinner.text = f"❌文件解析失败: {file_name}"
|
237
|
-
spinner.fail("")
|
238
|
-
return False
|
239
|
-
else:
|
200
|
+
print(f"🔍 处理文件 [{index}/{len(file_list)}]: {file_name}")
|
201
|
+
try:
|
202
|
+
mime_type, _ = mimetypes.guess_type(file_path)
|
203
|
+
action = (
|
204
|
+
"image" if mime_type and mime_type.startswith("image/") else "file"
|
205
|
+
)
|
206
|
+
|
207
|
+
# 获取预签名URL
|
208
|
+
print(f"🔍 获取上传URL: {file_name}")
|
209
|
+
presigned_data = self._get_presigned_url(file_path, action)
|
210
|
+
|
211
|
+
# 上传文件
|
212
|
+
print(f"🔍 上传文件: {file_name}")
|
213
|
+
if self._upload_file(file_path, presigned_data["url"]):
|
214
|
+
# 获取文件信息
|
215
|
+
print(f"🔍 获取文件信息: {file_name}")
|
216
|
+
file_info = self._get_file_info(presigned_data, file_name, action)
|
217
|
+
|
218
|
+
# 只有文件需要解析
|
219
|
+
if action == "file":
|
220
|
+
print(f"🔍 等待文件解析: {file_name}")
|
221
|
+
if self._wait_for_parse(file_info["id"]):
|
240
222
|
uploaded_files.append(file_info)
|
241
|
-
|
223
|
+
print(f"✅ 文件处理完成: {file_name}")
|
224
|
+
else:
|
225
|
+
print(f"❌ 文件解析失败: {file_name}")
|
226
|
+
return False
|
242
227
|
else:
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
except Exception as e:
|
248
|
-
spinner.text = f"处理文件出错 {file_path}: {str(e)}"
|
249
|
-
spinner.fail("❌")
|
228
|
+
uploaded_files.append(file_info)
|
229
|
+
print(f"✅ 图片处理完成: {file_name}")
|
230
|
+
else:
|
231
|
+
print(f"❌ 文件上传失败: {file_name}")
|
250
232
|
return False
|
251
233
|
|
234
|
+
except Exception as e:
|
235
|
+
print(f"❌ 处理文件出错 {file_path}: {str(e)}")
|
236
|
+
return False
|
237
|
+
|
252
238
|
self.uploaded_files = uploaded_files
|
253
239
|
return True
|
254
240
|
|
jarvis/jarvis_platform/tongyi.py
CHANGED
@@ -5,9 +5,7 @@ import time
|
|
5
5
|
import uuid
|
6
6
|
from typing import Any, Dict, Generator, List, Tuple
|
7
7
|
|
8
|
-
import requests
|
9
|
-
from yaspin import yaspin
|
10
|
-
from yaspin.spinners import Spinners
|
8
|
+
import requests # type: ignore
|
11
9
|
|
12
10
|
from jarvis.jarvis_platform.base import BasePlatform
|
13
11
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
@@ -289,140 +287,124 @@ class TongyiPlatform(BasePlatform):
|
|
289
287
|
|
290
288
|
for file_path in file_list:
|
291
289
|
file_name = os.path.basename(file_path)
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
return False
|
298
|
-
|
299
|
-
# Get file name and content type
|
300
|
-
content_type = self._get_content_type(file_path)
|
301
|
-
|
302
|
-
spinner.text = f"准备上传文件: {file_name}"
|
303
|
-
|
304
|
-
# Prepare form data
|
305
|
-
form_data = {
|
306
|
-
"OSSAccessKeyId": upload_token["accessId"],
|
307
|
-
"policy": upload_token["policy"],
|
308
|
-
"signature": upload_token["signature"],
|
309
|
-
"key": f"{upload_token['dir']}{file_name}",
|
310
|
-
"dir": upload_token["dir"],
|
311
|
-
"success_action_status": "200",
|
312
|
-
}
|
290
|
+
print(f"🔍 上传文件 {file_name}")
|
291
|
+
try:
|
292
|
+
if not os.path.exists(file_path):
|
293
|
+
print(f"❌ 文件不存在: {file_path}")
|
294
|
+
return False
|
313
295
|
|
314
|
-
|
315
|
-
|
316
|
-
"file": (file_name, open(file_path, "rb"), content_type)
|
317
|
-
}
|
296
|
+
# Get file name and content type
|
297
|
+
content_type = self._get_content_type(file_path)
|
318
298
|
|
319
|
-
|
299
|
+
print(f"🔍 准备上传文件: {file_name}")
|
320
300
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
301
|
+
# Prepare form data
|
302
|
+
form_data = {
|
303
|
+
"OSSAccessKeyId": upload_token["accessId"],
|
304
|
+
"policy": upload_token["policy"],
|
305
|
+
"signature": upload_token["signature"],
|
306
|
+
"key": f"{upload_token['dir']}{file_name}",
|
307
|
+
"dir": upload_token["dir"],
|
308
|
+
"success_action_status": "200",
|
309
|
+
}
|
325
310
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
)
|
311
|
+
# Prepare files
|
312
|
+
files = {"file": (file_name, open(file_path, "rb"), content_type)}
|
313
|
+
|
314
|
+
print(f"📤 正在上传文件: {file_name}")
|
315
|
+
|
316
|
+
# Upload file
|
317
|
+
response = requests.post(
|
318
|
+
upload_token["host"], data=form_data, files=files
|
319
|
+
)
|
320
|
+
|
321
|
+
if response.status_code != 200:
|
322
|
+
print(f"❌ 上传失败 {file_name}: HTTP {response.status_code}")
|
323
|
+
return False
|
324
|
+
|
325
|
+
# Determine file type based on extension
|
326
|
+
file_ext = os.path.splitext(file_path)[1].lower()
|
327
|
+
is_image = file_ext in self.IMAGE_EXTENSIONS
|
344
328
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
headers = self._get_base_headers()
|
350
|
-
payload = {
|
351
|
-
"fileKeys": [f["fileKey"] for f in uploaded_files],
|
352
|
-
"fileType": (
|
353
|
-
"image"
|
354
|
-
if any(f["fileType"] == "image" for f in uploaded_files)
|
355
|
-
else "file"
|
356
|
-
),
|
329
|
+
uploaded_files.append(
|
330
|
+
{
|
331
|
+
"fileKey": file_name,
|
332
|
+
"fileType": "image" if is_image else "file",
|
357
333
|
"dir": upload_token["dir"],
|
358
334
|
}
|
335
|
+
)
|
336
|
+
|
337
|
+
print(f"🔍 获取下载链接: {file_name}")
|
338
|
+
|
339
|
+
# Get download links for uploaded files
|
340
|
+
url = "https://api.tongyi.com/dialog/downloadLink/batch"
|
341
|
+
headers = self._get_base_headers()
|
342
|
+
payload = {
|
343
|
+
"fileKeys": [f["fileKey"] for f in uploaded_files],
|
344
|
+
"fileType": (
|
345
|
+
"image"
|
346
|
+
if any(f["fileType"] == "image" for f in uploaded_files)
|
347
|
+
else "file"
|
348
|
+
),
|
349
|
+
"dir": upload_token["dir"],
|
350
|
+
}
|
359
351
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
"
|
352
|
+
response = requests.post(url, headers=headers, json=payload)
|
353
|
+
if response.status_code != 200:
|
354
|
+
print(f"❌ 获取下载链接失败: HTTP {response.status_code}")
|
355
|
+
return False
|
356
|
+
|
357
|
+
result = response.json()
|
358
|
+
if not result.get("success"):
|
359
|
+
print(f"❌ 获取下载链接失败: {result.get('errorMsg')}")
|
360
|
+
return False
|
361
|
+
|
362
|
+
# Add files to chat
|
363
|
+
self.uploaded_file_info = result.get("data", {}).get("results", [])
|
364
|
+
for file_info in self.uploaded_file_info:
|
365
|
+
print(f"🔍 添加文件到对话: {file_name}")
|
366
|
+
add_url = "https://api.tongyi.com/assistant/api/chat/file/add"
|
367
|
+
add_payload = {
|
368
|
+
"workSource": "chat",
|
369
|
+
"terminal": "web",
|
370
|
+
"workCode": "0",
|
371
|
+
"channel": "home",
|
372
|
+
"workType": "file",
|
373
|
+
"module": "uploadhistory",
|
374
|
+
"workName": file_info["fileKey"],
|
375
|
+
"workId": file_info["docId"],
|
376
|
+
"workResourcePath": file_info["url"],
|
377
|
+
"sessionId": "",
|
378
|
+
"batchId": str(uuid.uuid4()).replace("-", "")[
|
379
|
+
:32
|
380
|
+
], # Generate random batchId
|
381
|
+
"fileSize": os.path.getsize(file_path),
|
382
|
+
}
|
383
|
+
|
384
|
+
add_response = requests.post(
|
385
|
+
add_url, headers=headers, json=add_payload
|
377
386
|
)
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
"https://api.tongyi.com/assistant/api/chat/file/add"
|
387
|
+
if add_response.status_code != 200:
|
388
|
+
print(
|
389
|
+
f"❌ 添加文件到对话失败: HTTP {add_response.status_code}"
|
382
390
|
)
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
"
|
389
|
-
"module": "uploadhistory",
|
390
|
-
"workName": file_info["fileKey"],
|
391
|
-
"workId": file_info["docId"],
|
392
|
-
"workResourcePath": file_info["url"],
|
393
|
-
"sessionId": "",
|
394
|
-
"batchId": str(uuid.uuid4()).replace("-", "")[
|
395
|
-
:32
|
396
|
-
], # Generate random batchId
|
397
|
-
"fileSize": os.path.getsize(file_path),
|
398
|
-
}
|
399
|
-
|
400
|
-
add_response = requests.post(
|
401
|
-
add_url, headers=headers, json=add_payload
|
391
|
+
continue
|
392
|
+
|
393
|
+
add_result = add_response.json()
|
394
|
+
if not add_result.get("success"):
|
395
|
+
print(
|
396
|
+
f"❌ 添加文件到对话失败: {add_result.get('errorMsg')}"
|
402
397
|
)
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
spinner.fail("❌")
|
414
|
-
continue
|
415
|
-
|
416
|
-
file_info.update(add_result.get("data", {}))
|
417
|
-
|
418
|
-
spinner.text = f"文件 {file_name} 上传成功"
|
419
|
-
spinner.ok("✅")
|
420
|
-
time.sleep(1) # 短暂暂停以便用户看到成功状态
|
421
|
-
|
422
|
-
except Exception as e:
|
423
|
-
spinner.text = f"上传文件 {file_name} 时出错: {str(e)}"
|
424
|
-
spinner.fail("❌")
|
425
|
-
return False
|
398
|
+
continue
|
399
|
+
|
400
|
+
file_info.update(add_result.get("data", {}))
|
401
|
+
|
402
|
+
print(f"✅ 文件 {file_name} 上传成功")
|
403
|
+
time.sleep(1) # 短暂暂停以便用户看到成功状态
|
404
|
+
|
405
|
+
except Exception as e:
|
406
|
+
print(f"❌ 上传文件 {file_name} 时出错: {str(e)}")
|
407
|
+
return False
|
426
408
|
return True
|
427
409
|
|
428
410
|
except Exception as e:
|