jarvis-ai-assistant 0.1.225__tar.gz → 0.2.1__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.
Files changed (117) hide show
  1. {jarvis_ai_assistant-0.1.225/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.2.1}/PKG-INFO +61 -13
  2. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/README.md +60 -12
  3. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/pyproject.toml +1 -1
  4. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/setup.py +1 -1
  5. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/__init__.py +1 -1
  6. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/__init__.py +8 -5
  7. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/jarvis.py +6 -0
  8. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/main.py +7 -0
  9. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_agent/code_agent.py +12 -1
  10. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/code_review.py +14 -3
  11. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_data/config_schema.json +41 -0
  12. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_git_utils/git_commiter.py +9 -2
  13. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_mcp/sse_mcp_client.py +9 -7
  14. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_mcp/stdio_mcp_client.py +2 -2
  15. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_multi_agent/__init__.py +7 -5
  16. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/base.py +28 -13
  17. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/generate_new_tool.py +1 -0
  18. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/registry.py +71 -28
  19. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/config.py +80 -21
  20. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/git_utils.py +2 -2
  21. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/globals.py +17 -11
  22. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/methodology.py +37 -23
  23. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/output.py +2 -2
  24. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/utils.py +137 -3
  25. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1/src/jarvis_ai_assistant.egg-info}/PKG-INFO +61 -13
  26. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/LICENSE +0 -0
  27. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/MANIFEST.in +0 -0
  28. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/setup.cfg +0 -0
  29. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/builtin_input_handler.py +0 -0
  30. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/edit_file_handler.py +0 -0
  31. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/output_handler.py +0 -0
  32. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/prompt_builder.py +0 -0
  33. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/prompts.py +0 -0
  34. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/protocols.py +0 -0
  35. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/session_manager.py +0 -0
  36. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/shell_input_handler.py +0 -0
  37. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_agent/tool_executor.py +0 -0
  38. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
  39. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_agent/lint.py +0 -0
  40. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/__init__.py +0 -0
  41. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/c_cpp.py +0 -0
  42. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/csharp.py +0 -0
  43. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/data_format.py +0 -0
  44. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/devops.py +0 -0
  45. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/docs.py +0 -0
  46. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/go.py +0 -0
  47. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/infrastructure.py +0 -0
  48. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/java.py +0 -0
  49. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/javascript.py +0 -0
  50. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/kotlin.py +0 -0
  51. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/loader.py +0 -0
  52. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/php.py +0 -0
  53. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/python.py +0 -0
  54. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/ruby.py +0 -0
  55. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/rust.py +0 -0
  56. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/shell.py +0 -0
  57. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/sql.py +0 -0
  58. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/swift.py +0 -0
  59. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_code_analysis/checklists/web.py +0 -0
  60. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_data/tiktoken/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 +0 -0
  61. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_git_details/__init__.py +0 -0
  62. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_git_details/main.py +0 -0
  63. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_git_squash/__init__.py +0 -0
  64. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_git_squash/main.py +0 -0
  65. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_mcp/__init__.py +0 -0
  66. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_mcp/streamable_mcp_client.py +0 -0
  67. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_methodology/main.py +0 -0
  68. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_multi_agent/main.py +0 -0
  69. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/__init__.py +0 -0
  70. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/ai8.py +0 -0
  71. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/human.py +0 -0
  72. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/kimi.py +0 -0
  73. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/openai.py +0 -0
  74. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/oyi.py +0 -0
  75. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/registry.py +0 -0
  76. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/tongyi.py +0 -0
  77. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform/yuanbao.py +0 -0
  78. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform_manager/__init__.py +0 -0
  79. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform_manager/main.py +0 -0
  80. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_platform_manager/service.py +0 -0
  81. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/__init__.py +0 -0
  82. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/cache.py +0 -0
  83. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/cli.py +0 -0
  84. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/embedding_manager.py +0 -0
  85. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/llm_interface.py +0 -0
  86. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/query_rewriter.py +0 -0
  87. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/rag_pipeline.py +0 -0
  88. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/reranker.py +0 -0
  89. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_rag/retriever.py +0 -0
  90. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
  91. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_smart_shell/main.py +0 -0
  92. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/__init__.py +0 -0
  93. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/ask_user.py +0 -0
  94. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/base.py +0 -0
  95. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/cli/__init__.py +0 -0
  96. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/cli/main.py +0 -0
  97. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/edit_file.py +0 -0
  98. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/execute_script.py +0 -0
  99. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/file_analyzer.py +0 -0
  100. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/methodology.py +0 -0
  101. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/read_code.py +0 -0
  102. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/read_webpage.py +0 -0
  103. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/rewrite_file.py +0 -0
  104. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/search_web.py +0 -0
  105. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_tools/virtual_tty.py +0 -0
  106. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/__init__.py +0 -0
  107. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/builtin_replace_map.py +0 -0
  108. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/embedding.py +0 -0
  109. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/file_processors.py +0 -0
  110. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/http.py +0 -0
  111. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/input.py +0 -0
  112. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis/jarvis_utils/tag.py +0 -0
  113. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  114. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  115. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  116. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  117. {jarvis_ai_assistant-0.1.225 → jarvis_ai_assistant-0.2.1}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.225
3
+ Version: 0.2.1
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
@@ -104,13 +104,25 @@ Dynamic: requires-python
104
104
  - Windows没有测试过,但Windows 10以上的用户可以在WSL上使用此工具
105
105
 
106
106
  ### 安装
107
+
108
+ #### 一键安装 (推荐)
109
+ 只需一行命令即可完成所有安装和配置:
110
+ ```bash
111
+ bash -c "$(curl -fsSL https://raw.githubusercontent.com/skyfireitdiy/Jarvis/main/scripts/install.sh)"
112
+ ```
113
+ > 该脚本会自动检测Python环境、克隆项目、安装依赖并设置好路径。
114
+
115
+ #### 手动安装
116
+
117
+ **1. 从源码安装**
107
118
  ```bash
108
- # 从源码安装(推荐)
109
119
  git clone https://github.com/skyfireitdiy/Jarvis
110
120
  cd Jarvis
111
121
  pip3 install -e .
122
+ ```
112
123
 
113
- # 或者从PyPI安装(可能更新不及时)
124
+ **2. PyPI安装 (可能不是最新版)**
125
+ ```bash
114
126
  pip3 install jarvis-ai-assistant
115
127
  ```
116
128
 
@@ -508,9 +520,9 @@ ENV:
508
520
  #### Kimi
509
521
  ```yaml
510
522
  JARVIS_PLATFORM: kimi
511
- JARVIS_MODEL: kimi
523
+ JARVIS_MODEL: k1.5
512
524
  JARVIS_THINKING_PLATFORM: kimi
513
- JARVIS_THINKING_MODEL: k1
525
+ JARVIS_THINKING_MODEL: k1.5-thinking
514
526
  ENV:
515
527
  KIMI_API_KEY: <Kimi API KEY>
516
528
  ```
@@ -535,19 +547,55 @@ OPENAI_API_KEY: <OpenAI API Key>
535
547
  OPENAI_API_BASE: https://api.openai.com/v1
536
548
  ```
537
549
 
538
- ### 2. 配置项说明
550
+ ### 2. 模型组配置 (高级)
551
+
552
+ 除了单独配置每个模型参数,您还可以定义和使用**模型组**来快速切换不同的模型组合。这对于需要在不同任务或平台间频繁切换的场景非常有用。
553
+
554
+ **配置示例** (`~/.jarvis/config.yaml`):
555
+
556
+ ```yaml
557
+ # 定义模型组
558
+ JARVIS_MODEL_GROUPS:
559
+ - kimi:
560
+ JARVIS_PLATFORM: kimi
561
+ JARVIS_MODEL: k1.5
562
+ JARVIS_THINKING_PLATFORM: kimi
563
+ JARVIS_THINKING_MODEL: k1.5-thinking
564
+ JARVIS_MAX_TOKEN_COUNT: 8192
565
+ - ai8:
566
+ JARVIS_PLATFORM: ai8
567
+ JARVIS_MODEL: gemini-2.5-pro
568
+ # 如果不指定思考模型,将自动使用常规模型
569
+ # JARVIS_THINKING_PLATFORM: ai8
570
+ # JARVIS_THINKING_MODEL: gemini-2.5-pro
571
+
572
+ # 选择要使用的模型组
573
+ JARVIS_MODEL_GROUP: kimi
574
+ ```
575
+
576
+ **配置优先级规则:**
577
+
578
+ Jarvis 会按照以下顺序解析模型配置,序号越小优先级越高:
579
+
580
+ 1. **独立配置**: 直接设置的 `JARVIS_PLATFORM`, `JARVIS_MODEL`, `JARVIS_THINKING_PLATFORM`, `JARVIS_THINKING_MODEL` 环境变量。这些配置会**覆盖**任何模型组中的设置。
581
+ 2. **模型组配置**: 通过 `JARVIS_MODEL_GROUP` 选中的模型组配置。
582
+ 3. **默认值**: 如果以上均未配置,则使用代码中定义的默认模型(如 `yuanbao` 和 `deep_seek_v3`)。
583
+
584
+ ### 3. 全部配置项说明
539
585
  | 变量名称 | 默认值 | 说明 |
540
586
  |----------|--------|------|
541
587
  | `ENV` | {} | 环境变量配置 |
542
- | `JARVIS_MAX_TOKEN_COUNT` | 960000 | 上下文窗口的最大token数量 |
543
- | `JARVIS_MAX_INPUT_TOKEN_COUNT` | 32000 | 输入的最大token数量 |
544
- | `JARVIS_PLATFORM` | yuanbao | 默认AI平台 |
545
- | `JARVIS_MODEL` | deep_seek_v3 | 默认模型 |
546
- | `JARVIS_THINKING_PLATFORM` | JARVIS_PLATFORM | 推理任务使用的平台 |
547
- | `JARVIS_THINKING_MODEL` | JARVIS_MODEL | 推理任务使用的模型 |
588
+ | `JARVIS_MODEL_GROUPS` | `[]` | 预定义的模型配置组列表 |
589
+ | `JARVIS_MODEL_GROUP` | `null` | 选择要激活的模型组名称 |
590
+ | `JARVIS_MAX_TOKEN_COUNT` | 960000 | 上下文窗口的最大token数量 (可被模型组覆盖) |
591
+ | `JARVIS_MAX_INPUT_TOKEN_COUNT` | 32000 | 输入的最大token数量 (可被模型组覆盖) |
592
+ | `JARVIS_PLATFORM` | yuanbao | 默认AI平台 (可被模型组覆盖) |
593
+ | `JARVIS_MODEL` | deep_seek_v3 | 默认模型 (可被模型组覆盖) |
594
+ | `JARVIS_THINKING_PLATFORM` | JARVIS_PLATFORM | 推理任务使用的平台 (可被模型组覆盖) |
595
+ | `JARVIS_THINKING_MODEL` | JARVIS_MODEL | 推理任务使用的模型 (可被模型组覆盖) |
548
596
  | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
549
597
  | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | false | 应用补丁前是否需要确认 |
550
- | `JARVIS_MAX_BIG_CONTENT_SIZE` | 160000 | 最大大内容大小 |
598
+ | `JARVIS_MAX_BIG_CONTENT_SIZE` | 160000 | 最大大内容大小 (可被模型组覆盖) |
551
599
  | `JARVIS_PRETTY_OUTPUT` | false | 是否启用PrettyOutput |
552
600
  | `JARVIS_GIT_COMMIT_PROMPT` | "" | 自定义git提交信息生成提示模板 |
553
601
  | `JARVIS_PRINT_PROMPT` | false | 是否打印提示 |
@@ -20,13 +20,25 @@
20
20
  - Windows没有测试过,但Windows 10以上的用户可以在WSL上使用此工具
21
21
 
22
22
  ### 安装
23
+
24
+ #### 一键安装 (推荐)
25
+ 只需一行命令即可完成所有安装和配置:
26
+ ```bash
27
+ bash -c "$(curl -fsSL https://raw.githubusercontent.com/skyfireitdiy/Jarvis/main/scripts/install.sh)"
28
+ ```
29
+ > 该脚本会自动检测Python环境、克隆项目、安装依赖并设置好路径。
30
+
31
+ #### 手动安装
32
+
33
+ **1. 从源码安装**
23
34
  ```bash
24
- # 从源码安装(推荐)
25
35
  git clone https://github.com/skyfireitdiy/Jarvis
26
36
  cd Jarvis
27
37
  pip3 install -e .
38
+ ```
28
39
 
29
- # 或者从PyPI安装(可能更新不及时)
40
+ **2. PyPI安装 (可能不是最新版)**
41
+ ```bash
30
42
  pip3 install jarvis-ai-assistant
31
43
  ```
32
44
 
@@ -424,9 +436,9 @@ ENV:
424
436
  #### Kimi
425
437
  ```yaml
426
438
  JARVIS_PLATFORM: kimi
427
- JARVIS_MODEL: kimi
439
+ JARVIS_MODEL: k1.5
428
440
  JARVIS_THINKING_PLATFORM: kimi
429
- JARVIS_THINKING_MODEL: k1
441
+ JARVIS_THINKING_MODEL: k1.5-thinking
430
442
  ENV:
431
443
  KIMI_API_KEY: <Kimi API KEY>
432
444
  ```
@@ -451,19 +463,55 @@ OPENAI_API_KEY: <OpenAI API Key>
451
463
  OPENAI_API_BASE: https://api.openai.com/v1
452
464
  ```
453
465
 
454
- ### 2. 配置项说明
466
+ ### 2. 模型组配置 (高级)
467
+
468
+ 除了单独配置每个模型参数,您还可以定义和使用**模型组**来快速切换不同的模型组合。这对于需要在不同任务或平台间频繁切换的场景非常有用。
469
+
470
+ **配置示例** (`~/.jarvis/config.yaml`):
471
+
472
+ ```yaml
473
+ # 定义模型组
474
+ JARVIS_MODEL_GROUPS:
475
+ - kimi:
476
+ JARVIS_PLATFORM: kimi
477
+ JARVIS_MODEL: k1.5
478
+ JARVIS_THINKING_PLATFORM: kimi
479
+ JARVIS_THINKING_MODEL: k1.5-thinking
480
+ JARVIS_MAX_TOKEN_COUNT: 8192
481
+ - ai8:
482
+ JARVIS_PLATFORM: ai8
483
+ JARVIS_MODEL: gemini-2.5-pro
484
+ # 如果不指定思考模型,将自动使用常规模型
485
+ # JARVIS_THINKING_PLATFORM: ai8
486
+ # JARVIS_THINKING_MODEL: gemini-2.5-pro
487
+
488
+ # 选择要使用的模型组
489
+ JARVIS_MODEL_GROUP: kimi
490
+ ```
491
+
492
+ **配置优先级规则:**
493
+
494
+ Jarvis 会按照以下顺序解析模型配置,序号越小优先级越高:
495
+
496
+ 1. **独立配置**: 直接设置的 `JARVIS_PLATFORM`, `JARVIS_MODEL`, `JARVIS_THINKING_PLATFORM`, `JARVIS_THINKING_MODEL` 环境变量。这些配置会**覆盖**任何模型组中的设置。
497
+ 2. **模型组配置**: 通过 `JARVIS_MODEL_GROUP` 选中的模型组配置。
498
+ 3. **默认值**: 如果以上均未配置,则使用代码中定义的默认模型(如 `yuanbao` 和 `deep_seek_v3`)。
499
+
500
+ ### 3. 全部配置项说明
455
501
  | 变量名称 | 默认值 | 说明 |
456
502
  |----------|--------|------|
457
503
  | `ENV` | {} | 环境变量配置 |
458
- | `JARVIS_MAX_TOKEN_COUNT` | 960000 | 上下文窗口的最大token数量 |
459
- | `JARVIS_MAX_INPUT_TOKEN_COUNT` | 32000 | 输入的最大token数量 |
460
- | `JARVIS_PLATFORM` | yuanbao | 默认AI平台 |
461
- | `JARVIS_MODEL` | deep_seek_v3 | 默认模型 |
462
- | `JARVIS_THINKING_PLATFORM` | JARVIS_PLATFORM | 推理任务使用的平台 |
463
- | `JARVIS_THINKING_MODEL` | JARVIS_MODEL | 推理任务使用的模型 |
504
+ | `JARVIS_MODEL_GROUPS` | `[]` | 预定义的模型配置组列表 |
505
+ | `JARVIS_MODEL_GROUP` | `null` | 选择要激活的模型组名称 |
506
+ | `JARVIS_MAX_TOKEN_COUNT` | 960000 | 上下文窗口的最大token数量 (可被模型组覆盖) |
507
+ | `JARVIS_MAX_INPUT_TOKEN_COUNT` | 32000 | 输入的最大token数量 (可被模型组覆盖) |
508
+ | `JARVIS_PLATFORM` | yuanbao | 默认AI平台 (可被模型组覆盖) |
509
+ | `JARVIS_MODEL` | deep_seek_v3 | 默认模型 (可被模型组覆盖) |
510
+ | `JARVIS_THINKING_PLATFORM` | JARVIS_PLATFORM | 推理任务使用的平台 (可被模型组覆盖) |
511
+ | `JARVIS_THINKING_MODEL` | JARVIS_MODEL | 推理任务使用的模型 (可被模型组覆盖) |
464
512
  | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
465
513
  | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | false | 应用补丁前是否需要确认 |
466
- | `JARVIS_MAX_BIG_CONTENT_SIZE` | 160000 | 最大大内容大小 |
514
+ | `JARVIS_MAX_BIG_CONTENT_SIZE` | 160000 | 最大大内容大小 (可被模型组覆盖) |
467
515
  | `JARVIS_PRETTY_OUTPUT` | false | 是否启用PrettyOutput |
468
516
  | `JARVIS_GIT_COMMIT_PROMPT` | "" | 自定义git提交信息生成提示模板 |
469
517
  | `JARVIS_PRINT_PROMPT` | false | 是否打印提示 |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.225"
7
+ version = "0.2.1"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "skyfire", email = "skyfireitdiy@hotmail.com" }]
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages # type: ignore
3
3
 
4
4
  setup(
5
5
  name="jarvis-ai-assistant",
6
- version="0.1.225",
6
+ version="0.2.1",
7
7
  author="skyfire",
8
8
  author_email="skyfireitdiy@hotmail.com",
9
9
  description="An AI assistant that uses various tools to interact with the system",
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Jarvis AI Assistant"""
3
3
 
4
- __version__ = "0.1.225"
4
+ __version__ = "0.2.1"
@@ -102,6 +102,7 @@ class Agent:
102
102
  name: str = "Jarvis",
103
103
  description: str = "",
104
104
  llm_type: str = "normal",
105
+ model_group: Optional[str] = None,
105
106
  summary_prompt: Optional[str] = None,
106
107
  auto_complete: bool = False,
107
108
  output_handler: List[OutputHandlerProtocol] = [],
@@ -137,11 +138,11 @@ class Agent:
137
138
  self.description = description
138
139
  # 初始化平台和模型
139
140
  if llm_type == "thinking":
140
- platform_name = get_thinking_platform_name()
141
- model_name = get_thinking_model_name()
141
+ platform_name = get_thinking_platform_name(model_group)
142
+ model_name = get_thinking_model_name(model_group)
142
143
  else: # 默认为 normal
143
- platform_name = get_normal_platform_name()
144
- model_name = get_normal_model_name()
144
+ platform_name = get_normal_platform_name(model_group)
145
+ model_name = get_normal_model_name(model_group)
145
146
 
146
147
  self.model = PlatformRegistry().create_platform(platform_name)
147
148
  if self.model is None:
@@ -153,6 +154,8 @@ class Agent:
153
154
  if model_name:
154
155
  self.model.set_model_name(model_name)
155
156
 
157
+ self.model.set_model_group(model_group)
158
+
156
159
  self.user_data: Dict[str, Any] = {}
157
160
 
158
161
  self.model.set_suppress_output(False)
@@ -197,7 +200,7 @@ class Agent:
197
200
  summary_prompt if summary_prompt else DEFAULT_SUMMARY_PROMPT
198
201
  )
199
202
 
200
- self.max_token_count = get_max_token_count()
203
+ self.max_token_count = get_max_token_count(model_group)
201
204
  self.auto_complete = auto_complete
202
205
  welcome_message = f"{name} 初始化完成 - 使用 {self.model.name()} 模型"
203
206
 
@@ -125,6 +125,11 @@ def _parse_args() -> argparse.Namespace:
125
125
  type=str,
126
126
  help="Directly input task content from command line",
127
127
  )
128
+ parser.add_argument(
129
+ "--model_group",
130
+ type=str,
131
+ help="Model group to use, overriding config",
132
+ )
128
133
  parser.add_argument("-f", "--config", type=str, help="Path to custom config file")
129
134
  parser.add_argument(
130
135
  "--restore-session",
@@ -170,6 +175,7 @@ def _initialize_agent(args: argparse.Namespace) -> Agent:
170
175
  agent = Agent(
171
176
  system_prompt=origin_agent_system_prompt,
172
177
  llm_type=args.llm_type,
178
+ model_group=args.model_group,
173
179
  input_handler=[shell_input_handler, builtin_input_handler],
174
180
  output_handler=[ToolRegistry()], # type: ignore
175
181
  need_summary=False,
@@ -52,6 +52,11 @@ def main():
52
52
  choices=["normal", "thinking"],
53
53
  help="LLM type to use, overriding config",
54
54
  )
55
+ parser.add_argument(
56
+ "--model_group",
57
+ type=str,
58
+ help="Model group to use, overriding config",
59
+ )
55
60
  args = parser.parse_args()
56
61
 
57
62
  # Initialize environment
@@ -65,6 +70,8 @@ def main():
65
70
  # Override config with command-line arguments if provided
66
71
  if args.llm_type:
67
72
  config["llm_type"] = args.llm_type
73
+ if args.model_group:
74
+ config["model_group"] = args.model_group
68
75
 
69
76
  # Create and run agent
70
77
  try:
@@ -47,6 +47,7 @@ class CodeAgent:
47
47
  def __init__(
48
48
  self,
49
49
  llm_type: str = "normal",
50
+ model_group: Optional[str] = None,
50
51
  need_summary: bool = True,
51
52
  ):
52
53
  self.root_dir = os.getcwd()
@@ -120,6 +121,7 @@ class CodeAgent:
120
121
  auto_complete=False,
121
122
  output_handler=[tool_registry, EditFileHandler()], # type: ignore
122
123
  llm_type=llm_type,
124
+ model_group=model_group,
123
125
  input_handler=[shell_input_handler, builtin_input_handler],
124
126
  need_summary=need_summary,
125
127
  use_methodology=False, # 禁用方法论
@@ -411,6 +413,11 @@ def main() -> None:
411
413
  choices=["normal", "thinking"],
412
414
  help="LLM type to use",
413
415
  )
416
+ parser.add_argument(
417
+ "--model_group",
418
+ type=str,
419
+ help="Model group to use, overriding config",
420
+ )
414
421
  parser.add_argument(
415
422
  "-r", "--requirement", type=str, help="Requirement to process", default=None
416
423
  )
@@ -427,7 +434,11 @@ def main() -> None:
427
434
  PrettyOutput.print(f"当前目录: {git_dir}", OutputType.INFO)
428
435
 
429
436
  try:
430
- agent = CodeAgent(llm_type=args.llm_type, need_summary=False)
437
+ agent = CodeAgent(
438
+ llm_type=args.llm_type,
439
+ model_group=args.model_group,
440
+ need_summary=False,
441
+ )
431
442
 
432
443
  # 尝试恢复会话
433
444
  if args.restore_session:
@@ -3,12 +3,13 @@ import os
3
3
  import re
4
4
  import subprocess
5
5
  import tempfile
6
- from typing import Any, Dict, List
6
+ from typing import Any, Dict, List, Optional
7
7
 
8
8
  from jarvis.jarvis_agent import Agent
9
9
  from jarvis.jarvis_code_analysis.checklists.loader import get_language_checklist
10
10
  from jarvis.jarvis_platform.registry import PlatformRegistry
11
11
  from jarvis.jarvis_tools.read_code import ReadCodeTool
12
+ from jarvis.jarvis_utils.globals import get_agent, current_agent_name
12
13
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
13
14
  from jarvis.jarvis_utils.tag import ct, ot
14
15
  from jarvis.jarvis_utils.utils import init_env, is_context_overflow
@@ -261,7 +262,9 @@ class CodeReviewTool:
261
262
  checklist = get_language_checklist(language)
262
263
  return checklist if checklist else ""
263
264
 
264
- def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
265
+ def execute(
266
+ self, args: Dict[str, Any], agent: Optional["Agent"] = None
267
+ ) -> Dict[str, Any]:
265
268
  try:
266
269
  review_type = args.get("review_type", "current").strip()
267
270
  root_dir = args.get("root_dir", ".")
@@ -570,9 +573,17 @@ class CodeReviewTool:
570
573
 
571
574
  tool_registry = ToolRegistry()
572
575
  tool_registry.dont_use_tools(["code_review"])
576
+
577
+ # Use the provided agent's model_group or get it from globals
578
+ calling_agent = agent or get_agent(current_agent_name)
579
+ model_group = None
580
+ if calling_agent and hasattr(calling_agent, "model") and calling_agent.model:
581
+ model_group = calling_agent.model.model_group
582
+
573
583
  agent = Agent(
574
584
  system_prompt=system_prompt,
575
585
  name="Code Review Agent",
586
+ model_group=model_group,
576
587
  summary_prompt=f"""<code_review_report>
577
588
  <overview>
578
589
  # 整体评估
@@ -675,7 +686,7 @@ class CodeReviewTool:
675
686
 
676
687
  try:
677
688
  # Check if content is too large
678
- is_large_content = is_context_overflow(diff_output)
689
+ is_large_content = is_context_overflow(diff_output, model_group)
679
690
 
680
691
  # Upload the file to the agent's model
681
692
  if is_large_content:
@@ -141,6 +141,47 @@
141
141
  "description": "思考操作模型名称",
142
142
  "default": "deep_seek"
143
143
  },
144
+ "JARVIS_MODEL_GROUP": {
145
+ "type": "string",
146
+ "description": "选择一个预定义的模型组"
147
+ },
148
+ "JARVIS_MODEL_GROUPS": {
149
+ "type": "array",
150
+ "description": "预定义的模型配置组",
151
+ "items": {
152
+ "type": "object",
153
+ "additionalProperties": {
154
+ "type": "object",
155
+ "properties": {
156
+ "JARVIS_PLATFORM": {
157
+ "type": "string"
158
+ },
159
+ "JARVIS_MODEL": {
160
+ "type": "string"
161
+ },
162
+ "JARVIS_THINKING_PLATFORM": {
163
+ "type": "string"
164
+ },
165
+ "JARVIS_THINKING_MODEL": {
166
+ "type": "string"
167
+ },
168
+ "JARVIS_MAX_TOKEN_COUNT": {
169
+ "type": "number"
170
+ },
171
+ "JARVIS_MAX_INPUT_TOKEN_COUNT": {
172
+ "type": "number"
173
+ },
174
+ "JARVIS_MAX_BIG_CONTENT_SIZE": {
175
+ "type": "number"
176
+ }
177
+ },
178
+ "required": [
179
+ "JARVIS_PLATFORM",
180
+ "JARVIS_MODEL"
181
+ ]
182
+ }
183
+ }
184
+ },
144
185
  "JARVIS_EXECUTE_TOOL_CONFIRM": {
145
186
  "type": "boolean",
146
187
  "description": "执行工具前是否需要确认",
@@ -16,6 +16,7 @@ from jarvis.jarvis_utils.git_utils import (
16
16
  find_git_root_and_cd,
17
17
  has_uncommitted_changes,
18
18
  )
19
+ from jarvis.jarvis_utils.globals import get_agent, current_agent_name
19
20
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
20
21
  from jarvis.jarvis_utils.tag import ct, ot
21
22
  from jarvis.jarvis_utils.utils import init_env, is_context_overflow
@@ -162,11 +163,17 @@ commit信息
162
163
  """
163
164
 
164
165
  # 获取模型并尝试上传文件
165
- platform = PlatformRegistry().get_normal_platform()
166
+ agent = get_agent(current_agent_name)
167
+ if agent:
168
+ platform = agent.model
169
+ model_group = agent.model.model_group
170
+ else:
171
+ platform = PlatformRegistry().get_normal_platform()
172
+ model_group = None
166
173
  upload_success = False
167
174
 
168
175
  # Check if content is too large
169
- is_large_content = is_context_overflow(diff)
176
+ is_large_content = is_context_overflow(diff, model_group)
170
177
 
171
178
  if is_large_content:
172
179
  if not platform.support_upload_files():
@@ -2,7 +2,7 @@
2
2
  import json
3
3
  import threading
4
4
  import time
5
- from typing import Any, Callable, Dict, List
5
+ from typing import Any, Callable, Dict, List, Optional
6
6
  from urllib.parse import parse_qs, urlencode, urljoin
7
7
 
8
8
  import requests
@@ -46,10 +46,10 @@ class SSEMcpClient(McpClient):
46
46
  self.session.headers.update(extra_headers)
47
47
 
48
48
  # SSE相关属性
49
- self.sse_response = None
50
- self.sse_thread = None
51
- self.messages_endpoint = None
52
- self.session_id = None # 从SSE连接获取的会话ID
49
+ self.sse_response: Optional[requests.Response] = None
50
+ self.sse_thread: Optional[threading.Thread] = None
51
+ self.messages_endpoint: Optional[str] = None
52
+ self.session_id: Optional[str] = None
53
53
  self.pending_requests = {} # 存储等待响应的请求 {id: Event}
54
54
  self.request_results = {} # 存储请求结果 {id: result}
55
55
  self.notification_handlers = {}
@@ -123,13 +123,15 @@ class SSEMcpClient(McpClient):
123
123
  self.sse_response = self.session.get(
124
124
  sse_url, stream=True, headers=sse_headers, timeout=30
125
125
  )
126
- self.sse_response.raise_for_status()
126
+ if self.sse_response:
127
+ self.sse_response.raise_for_status()
127
128
 
128
129
  # 启动事件处理线程
129
130
  self.sse_thread = threading.Thread(
130
131
  target=self._process_sse_events, daemon=True
131
132
  )
132
- self.sse_thread.start()
133
+ if self.sse_thread:
134
+ self.sse_thread.start()
133
135
 
134
136
  except Exception as e:
135
137
  PrettyOutput.print(f"SSE连接失败: {str(e)}", OutputType.ERROR)
@@ -2,7 +2,7 @@
2
2
  import json
3
3
  import os
4
4
  import subprocess
5
- from typing import Any, Dict, List
5
+ from typing import Any, Dict, List, Optional
6
6
 
7
7
  from jarvis.jarvis_mcp import McpClient
8
8
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
@@ -17,7 +17,7 @@ class StdioMcpClient(McpClient):
17
17
 
18
18
  def __init__(self, config: Dict[str, Any]):
19
19
  self.config = config
20
- self.process = None
20
+ self.process: Optional[subprocess.Popen] = None
21
21
  self.protocol_version = "2025-03-26" # MCP协议版本
22
22
  self._start_process()
23
23
  self._initialize()
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import re
3
- from typing import Any, Dict, List, Optional, Tuple
3
+ from typing import Any, Dict, List, Optional, Tuple, Union
4
4
 
5
5
  import yaml
6
6
 
@@ -89,6 +89,8 @@ content: |2
89
89
  Args:
90
90
  content: The content containing send message
91
91
  """
92
+ if ot("SEND_MESSAGE") in content and ct("SEND_MESSAGE") not in content:
93
+ content += "\n" + ct("SEND_MESSAGE")
92
94
  data = re.findall(
93
95
  ot("SEND_MESSAGE") + r"\n(.*?)\n" + ct("SEND_MESSAGE"), content, re.DOTALL
94
96
  )
@@ -102,7 +104,7 @@ content: |2
102
104
  continue
103
105
  return ret
104
106
 
105
- def _get_agent(self, name: str) -> Agent | None:
107
+ def _get_agent(self, name: str) -> Union[Agent, None]:
106
108
  if name in self.agents:
107
109
  return self.agents[name]
108
110
 
@@ -113,9 +115,9 @@ content: |2
113
115
 
114
116
  if name != self.main_agent_name and self.original_question:
115
117
  system_prompt = config.get("system_prompt", "")
116
- config["system_prompt"] = (
117
- f"{system_prompt}\n\n# 原始问题\n{self.original_question}"
118
- )
118
+ config[
119
+ "system_prompt"
120
+ ] = f"{system_prompt}\n\n# 原始问题\n{self.original_question}"
119
121
 
120
122
  output_handler = config.get("output_handler", [])
121
123
  if len(output_handler) == 0:
@@ -1,7 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import re
3
3
  from abc import ABC, abstractmethod
4
- from typing import Generator, List, Tuple
4
+ from types import TracebackType
5
+ from typing import Generator, List, Optional, Tuple, Type
6
+
7
+ from typing_extensions import Self
5
8
 
6
9
  from rich import box # type: ignore
7
10
  from rich.live import Live # type: ignore
@@ -28,9 +31,19 @@ class BasePlatform(ABC):
28
31
  self.suppress_output = True # 添加输出控制标志
29
32
  self.web = False # 添加web属性,默认false
30
33
  self._saved = False
31
-
32
- def __del__(self):
33
- """Destroy model"""
34
+ self.model_group: Optional[str] = None
35
+
36
+ def __enter__(self) -> Self:
37
+ """Enter context manager"""
38
+ return self
39
+
40
+ def __exit__(
41
+ self,
42
+ exc_type: Optional[Type[BaseException]],
43
+ exc_val: Optional[BaseException],
44
+ exc_tb: Optional[TracebackType],
45
+ ) -> None:
46
+ """Exit context manager"""
34
47
  if not self._saved:
35
48
  self.delete_chat()
36
49
 
@@ -64,9 +77,11 @@ class BasePlatform(ABC):
64
77
 
65
78
  input_token_count = get_context_token_count(message)
66
79
 
67
- if input_token_count > get_max_input_token_count():
68
- max_chunk_size = get_max_input_token_count() - 1024 # 留出一些余量
69
- min_chunk_size = get_max_input_token_count() - 2048
80
+ if input_token_count > get_max_input_token_count(self.model_group):
81
+ max_chunk_size = (
82
+ get_max_input_token_count(self.model_group) - 1024
83
+ ) # 留出一些余量
84
+ min_chunk_size = get_max_input_token_count(self.model_group) - 2048
70
85
  inputs = split_text_into_chunks(message, max_chunk_size, min_chunk_size)
71
86
  print("📤 正在提交长上下文...")
72
87
  prefix_prompt = f"""
@@ -95,14 +110,10 @@ class BasePlatform(ABC):
95
110
  ):
96
111
  response += trunk
97
112
 
98
- print(
99
- f"📤 提交第{submit_count}部分完成,当前进度:{length}/{len(message)}"
100
- )
113
+ print(f"📤 提交第{submit_count}部分完成,当前进度:{length}/{len(message)}")
101
114
  print("✅ 提交完成")
102
115
  response += "\n" + while_true(
103
- lambda: while_success(
104
- lambda: self._chat("内容已经全部提供完毕,请根据内容继续"), 5
105
- ),
116
+ lambda: while_success(lambda: self._chat("内容已经全部提供完毕,请根据内容继续"), 5),
106
117
  5,
107
118
  )
108
119
  else:
@@ -233,6 +244,10 @@ class BasePlatform(ABC):
233
244
  """Set whether to suppress output"""
234
245
  self.suppress_output = suppress
235
246
 
247
+ def set_model_group(self, model_group: Optional[str]):
248
+ """Set model group"""
249
+ self.model_group = model_group
250
+
236
251
  def set_web(self, web: bool):
237
252
  """Set web flag"""
238
253
  self.web = web