jarvis-ai-assistant 0.1.225__py3-none-any.whl → 0.2.1__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.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import os
3
3
  from functools import lru_cache
4
- from typing import Any, Dict, List
4
+ from typing import Any, Dict, List, Optional
5
5
 
6
6
  import yaml # type: ignore
7
7
 
@@ -76,24 +76,26 @@ def get_replace_map() -> dict:
76
76
  return {**BUILTIN_REPLACE_MAP, **file_map}
77
77
 
78
78
 
79
- def get_max_token_count() -> int:
79
+ def get_max_token_count(model_group_override: Optional[str] = None) -> int:
80
80
  """
81
81
  获取模型允许的最大token数量。
82
82
 
83
83
  返回:
84
84
  int: 模型能处理的最大token数量。
85
85
  """
86
- return int(GLOBAL_CONFIG_DATA.get("JARVIS_MAX_TOKEN_COUNT", "960000"))
86
+ config = _get_resolved_model_config(model_group_override)
87
+ return int(config.get("JARVIS_MAX_TOKEN_COUNT", "960000"))
87
88
 
88
89
 
89
- def get_max_input_token_count() -> int:
90
+ def get_max_input_token_count(model_group_override: Optional[str] = None) -> int:
90
91
  """
91
92
  获取模型允许的最大输入token数量。
92
93
 
93
94
  返回:
94
95
  int: 模型能处理的最大输入token数量。
95
96
  """
96
- return int(GLOBAL_CONFIG_DATA.get("JARVIS_MAX_INPUT_TOKEN_COUNT", "32000"))
97
+ config = _get_resolved_model_config(model_group_override)
98
+ return int(config.get("JARVIS_MAX_INPUT_TOKEN_COUNT", "32000"))
97
99
 
98
100
 
99
101
  def get_shell_name() -> str:
@@ -113,48 +115,94 @@ def get_shell_name() -> str:
113
115
  return os.path.basename(shell_path).lower()
114
116
 
115
117
 
116
- def get_normal_platform_name() -> str:
118
+ def _get_resolved_model_config(model_group_override: Optional[str] = None) -> Dict[str, Any]:
119
+ """
120
+ 解析并合并模型配置,处理模型组。
121
+
122
+ 优先级顺序:
123
+ 1. 单独的环境变量 (JARVIS_PLATFORM, JARVIS_MODEL, etc.)
124
+ 2. JARVIS_MODEL_GROUP 中定义的组配置
125
+ 3. 代码中的默认值
126
+
127
+ 返回:
128
+ Dict[str, Any]: 解析后的模型配置字典
129
+ """
130
+ group_config = {}
131
+ model_group_name = model_group_override or GLOBAL_CONFIG_DATA.get("JARVIS_MODEL_GROUP")
132
+ # The format is a list of single-key dicts: [{'group_name': {...}}, ...]
133
+ model_groups = GLOBAL_CONFIG_DATA.get("JARVIS_MODEL_GROUPS", [])
134
+
135
+ if model_group_name and isinstance(model_groups, list):
136
+ for group_item in model_groups:
137
+ if isinstance(group_item, dict) and model_group_name in group_item:
138
+ group_config = group_item[model_group_name]
139
+ break
140
+
141
+ # Start with group config
142
+ resolved_config = group_config.copy()
143
+
144
+ # Override with specific settings from GLOBAL_CONFIG_DATA
145
+ for key in [
146
+ "JARVIS_PLATFORM",
147
+ "JARVIS_MODEL",
148
+ "JARVIS_THINKING_PLATFORM",
149
+ "JARVIS_THINKING_MODEL",
150
+ "JARVIS_MAX_TOKEN_COUNT",
151
+ "JARVIS_MAX_INPUT_TOKEN_COUNT",
152
+ "JARVIS_MAX_BIG_CONTENT_SIZE",
153
+ ]:
154
+ if key in GLOBAL_CONFIG_DATA:
155
+ resolved_config[key] = GLOBAL_CONFIG_DATA[key]
156
+
157
+ return resolved_config
158
+
159
+
160
+ def get_normal_platform_name(model_group_override: Optional[str] = None) -> str:
117
161
  """
118
162
  获取正常操作的平台名称。
119
163
 
120
164
  返回:
121
165
  str: 平台名称,默认为'yuanbao'
122
166
  """
123
- return GLOBAL_CONFIG_DATA.get("JARVIS_PLATFORM", "yuanbao")
167
+ config = _get_resolved_model_config(model_group_override)
168
+ return config.get("JARVIS_PLATFORM", "yuanbao")
124
169
 
125
170
 
126
- def get_normal_model_name() -> str:
171
+ def get_normal_model_name(model_group_override: Optional[str] = None) -> str:
127
172
  """
128
173
  获取正常操作的模型名称。
129
174
 
130
175
  返回:
131
- str: 模型名称,默认为'deep_seek'
176
+ str: 模型名称,默认为'deep_seek_v3'
132
177
  """
133
- return GLOBAL_CONFIG_DATA.get("JARVIS_MODEL", "deep_seek_v3")
178
+ config = _get_resolved_model_config(model_group_override)
179
+ return config.get("JARVIS_MODEL", "deep_seek_v3")
134
180
 
135
181
 
136
- def get_thinking_platform_name() -> str:
182
+ def get_thinking_platform_name(model_group_override: Optional[str] = None) -> str:
137
183
  """
138
184
  获取思考操作的平台名称。
139
185
 
140
186
  返回:
141
- str: 平台名称,默认为'yuanbao'
187
+ str: 平台名称,默认为正常操作平台
142
188
  """
143
- return GLOBAL_CONFIG_DATA.get(
144
- "JARVIS_THINKING_PLATFORM", GLOBAL_CONFIG_DATA.get("JARVIS_PLATFORM", "yuanbao")
189
+ config = _get_resolved_model_config(model_group_override)
190
+ # Fallback to normal platform if thinking platform is not specified
191
+ return config.get(
192
+ "JARVIS_THINKING_PLATFORM", get_normal_platform_name(model_group_override)
145
193
  )
146
194
 
147
195
 
148
- def get_thinking_model_name() -> str:
196
+ def get_thinking_model_name(model_group_override: Optional[str] = None) -> str:
149
197
  """
150
198
  获取思考操作的模型名称。
151
199
 
152
200
  返回:
153
- str: 模型名称,默认为'deep_seek'
201
+ str: 模型名称,默认为正常操作模型
154
202
  """
155
- return GLOBAL_CONFIG_DATA.get(
156
- "JARVIS_THINKING_MODEL", GLOBAL_CONFIG_DATA.get("JARVIS_MODEL", "deep_seek")
157
- )
203
+ config = _get_resolved_model_config(model_group_override)
204
+ # Fallback to normal model if thinking model is not specified
205
+ return config.get("JARVIS_THINKING_MODEL", get_normal_model_name(model_group_override))
158
206
 
159
207
 
160
208
  def is_execute_tool_confirm() -> bool:
@@ -190,14 +238,15 @@ def get_data_dir() -> str:
190
238
  )
191
239
 
192
240
 
193
- def get_max_big_content_size() -> int:
241
+ def get_max_big_content_size(model_group_override: Optional[str] = None) -> int:
194
242
  """
195
243
  获取最大大内容大小。
196
244
 
197
245
  返回:
198
246
  int: 最大大内容大小
199
247
  """
200
- return int(GLOBAL_CONFIG_DATA.get("JARVIS_MAX_BIG_CONTENT_SIZE", "160000"))
248
+ config = _get_resolved_model_config(model_group_override)
249
+ return int(config.get("JARVIS_MAX_BIG_CONTENT_SIZE", "160000"))
201
250
 
202
251
 
203
252
  def get_pretty_output() -> bool:
@@ -240,6 +289,16 @@ def get_tool_load_dirs() -> List[str]:
240
289
  return GLOBAL_CONFIG_DATA.get("JARVIS_TOOL_LOAD_DIRS", [])
241
290
 
242
291
 
292
+ def get_methodology_dirs() -> List[str]:
293
+ """
294
+ 获取方法论加载目录。
295
+
296
+ 返回:
297
+ List[str]: 方法论加载目录列表
298
+ """
299
+ return GLOBAL_CONFIG_DATA.get("JARVIS_METHODOLOGY_DIRS", [])
300
+
301
+
243
302
  def is_print_prompt() -> bool:
244
303
  """
245
304
  获取是否打印提示。
@@ -538,12 +538,12 @@ def get_recent_commits_with_files() -> List[Dict[str, Any]]:
538
538
  return []
539
539
 
540
540
  # 解析提交信息
541
- commits = []
541
+ commits: List[Dict[str, Any]] = []
542
542
  lines = result.stdout.splitlines()
543
543
  for i in range(0, len(lines), 4):
544
544
  if i + 3 >= len(lines):
545
545
  break
546
- commit = {
546
+ commit: Dict[str, Any] = {
547
547
  "hash": lines[i],
548
548
  "message": lines[i + 1],
549
549
  "author": lines[i + 2],
@@ -11,7 +11,7 @@ import os
11
11
 
12
12
  # 全局变量:保存最后一条消息
13
13
  last_message: str = ""
14
- from typing import Any, Set
14
+ from typing import Any, Dict, Set
15
15
 
16
16
  import colorama
17
17
  from rich.console import Console
@@ -22,7 +22,7 @@ colorama.init()
22
22
  # 禁用tokenizers并行以避免多进程问题
23
23
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
24
24
  # 全局代理管理
25
- global_agents: Set[str] = set()
25
+ global_agents: Dict[str, Any] = {}
26
26
  current_agent_name: str = ""
27
27
  # 表示与大模型交互的深度(>0表示正在交互)
28
28
  g_in_chat: int = 0
@@ -66,6 +66,19 @@ def make_agent_name(agent_name: str) -> str:
66
66
  return agent_name
67
67
 
68
68
 
69
+ def get_agent(agent_name: str) -> Any:
70
+ """
71
+ 获取指定名称的代理实例。
72
+
73
+ 参数:
74
+ agent_name: 代理名称
75
+
76
+ 返回:
77
+ Any: 代理实例,如果不存在则返回None
78
+ """
79
+ return global_agents.get(agent_name)
80
+
81
+
69
82
  def set_agent(agent_name: str, agent: Any) -> None:
70
83
  """
71
84
  设置当前代理并将其添加到全局代理集合中。
@@ -74,7 +87,7 @@ def set_agent(agent_name: str, agent: Any) -> None:
74
87
  agent_name: 代理名称
75
88
  agent: 代理对象
76
89
  """
77
- global_agents.add(agent_name)
90
+ global_agents[agent_name] = agent
78
91
  global current_agent_name
79
92
  current_agent_name = agent_name
80
93
 
@@ -101,7 +114,7 @@ def delete_agent(agent_name: str) -> None:
101
114
  agent_name: 要删除的代理名称
102
115
  """
103
116
  if agent_name in global_agents:
104
- global_agents.remove(agent_name)
117
+ del global_agents[agent_name]
105
118
  global current_agent_name
106
119
  current_agent_name = ""
107
120
 
@@ -173,10 +186,3 @@ def get_last_message() -> str:
173
186
  str: 最后一条消息
174
187
  """
175
188
  return last_message
176
- """
177
- 获取当前中断信号状态。
178
-
179
- 返回:
180
- int: 当前中断计数
181
- """
182
- return g_interrupt
@@ -10,14 +10,15 @@
10
10
  import json
11
11
  import os
12
12
  import tempfile
13
+ from pathlib import Path
13
14
  from typing import Any, Dict, List, Optional
14
15
 
15
16
  from jarvis.jarvis_platform.base import BasePlatform
16
17
  from jarvis.jarvis_platform.registry import PlatformRegistry
17
- from jarvis.jarvis_utils.config import get_data_dir
18
+ from jarvis.jarvis_utils.config import get_data_dir, get_methodology_dirs
19
+ from jarvis.jarvis_utils.globals import get_agent, current_agent_name
18
20
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
19
- from jarvis.jarvis_utils.utils import is_context_overflow
20
-
21
+ from jarvis.jarvis_utils.utils import is_context_overflow, daily_check_git_updates
21
22
 
22
23
  def _get_methodology_directory() -> str:
23
24
  """
@@ -37,32 +38,39 @@ def _get_methodology_directory() -> str:
37
38
 
38
39
  def _load_all_methodologies() -> Dict[str, str]:
39
40
  """
40
- 加载所有方法论文件
41
+ 从默认目录和配置的外部目录加载所有方法论文件。
41
42
 
42
43
  返回:
43
- Dict[str, str]: 方法论字典,键为问题类型,值为方法论内容
44
+ Dict[str, str]: 方法论字典,键为问题类型,值为方法论内容。
44
45
  """
45
- methodology_dir = _get_methodology_directory()
46
46
  all_methodologies = {}
47
+ methodology_dirs = [_get_methodology_directory()] + get_methodology_dirs()
47
48
 
48
- if not os.path.exists(methodology_dir):
49
- return all_methodologies
49
+ # --- 全局每日更新检查 ---
50
+ daily_check_git_updates(methodology_dirs, "methodologies")
50
51
 
51
52
  import glob
52
53
 
53
- for filepath in glob.glob(os.path.join(methodology_dir, "*.json")):
54
- try:
55
- with open(filepath, "r", encoding="utf-8", errors="ignore") as f:
56
- methodology = json.load(f)
57
- problem_type = methodology.get("problem_type", "")
58
- content = methodology.get("content", "")
59
- if problem_type and content:
60
- all_methodologies[problem_type] = content
61
- except Exception as e:
62
- filename = os.path.basename(filepath)
63
- PrettyOutput.print(
64
- f"加载方法论文件 {filename} 失败: {str(e)}", OutputType.WARNING
65
- )
54
+ for directory in set(methodology_dirs): # Use set to avoid duplicates
55
+ if not os.path.isdir(directory):
56
+ PrettyOutput.print(f"警告: 方法论目录不存在或不是一个目录: {directory}", OutputType.WARNING)
57
+ continue
58
+
59
+ for filepath in glob.glob(os.path.join(directory, "*.json")):
60
+ try:
61
+ with open(filepath, "r", encoding="utf-8", errors="ignore") as f:
62
+ methodology = json.load(f)
63
+ problem_type = methodology.get("problem_type", "")
64
+ content = methodology.get("content", "")
65
+ if problem_type and content:
66
+ if problem_type in all_methodologies:
67
+ PrettyOutput.print(f"警告: 方法论 '{problem_type}' 被 '{filepath}' 覆盖。", OutputType.WARNING)
68
+ all_methodologies[problem_type] = content
69
+ except Exception as e:
70
+ filename = os.path.basename(filepath)
71
+ PrettyOutput.print(
72
+ f"加载方法论文件 {filename} 失败: {str(e)}", OutputType.WARNING
73
+ )
66
74
 
67
75
  return all_methodologies
68
76
 
@@ -163,7 +171,13 @@ def load_methodology(user_input: str, tool_registery: Optional[Any] = None) -> s
163
171
  print(f"✅ 加载方法论文件完成 (共 {len(methodologies)} 个)")
164
172
 
165
173
  # 获取当前平台
166
- platform = PlatformRegistry().get_normal_platform()
174
+ agent = get_agent(current_agent_name)
175
+ if agent:
176
+ platform = agent.model
177
+ model_group = agent.model.model_group
178
+ else:
179
+ platform = PlatformRegistry().get_normal_platform()
180
+ model_group = None
167
181
  platform.set_suppress_output(False)
168
182
  if not platform:
169
183
  return ""
@@ -198,7 +212,7 @@ def load_methodology(user_input: str, tool_registery: Optional[Any] = None) -> s
198
212
  """
199
213
 
200
214
  # 检查内容是否过大
201
- is_large_content = is_context_overflow(full_content)
215
+ is_large_content = is_context_overflow(full_content, model_group)
202
216
  temp_file_path = None
203
217
 
204
218
  try:
@@ -10,7 +10,7 @@
10
10
  """
11
11
  from datetime import datetime
12
12
  from enum import Enum
13
- from typing import Optional, Tuple
13
+ from typing import Dict, Optional, Tuple, Any
14
14
 
15
15
  from pygments.lexers import guess_lexer
16
16
  from pygments.util import ClassNotFound
@@ -175,7 +175,7 @@ class PrettyOutput:
175
175
  lang: 语法高亮的语言
176
176
  traceback: 是否显示错误的回溯信息
177
177
  """
178
- styles = {
178
+ styles: Dict[OutputType, Dict[str, Any]] = {
179
179
  OutputType.SYSTEM: dict(bgcolor="#1e2b3c"),
180
180
  OutputType.CODE: dict(bgcolor="#1c2b1c"),
181
181
  OutputType.RESULT: dict(bgcolor="#1c1c2b"),
@@ -7,7 +7,8 @@ import subprocess
7
7
  import sys
8
8
  import time
9
9
  from pathlib import Path
10
- from typing import Any, Callable, Dict, Optional
10
+ from typing import Any, Callable, Dict, List, Optional
11
+ from datetime import datetime
11
12
 
12
13
  import yaml # type: ignore
13
14
 
@@ -416,9 +417,13 @@ def count_cmd_usage() -> None:
416
417
  _update_cmd_stats(sys.argv[0])
417
418
 
418
419
 
419
- def is_context_overflow(content: str) -> bool:
420
+ def is_context_overflow(
421
+ content: str, model_group_override: Optional[str] = None
422
+ ) -> bool:
420
423
  """判断文件内容是否超出上下文限制"""
421
- return get_context_token_count(content) > get_max_big_content_size()
424
+ return get_context_token_count(content) > get_max_big_content_size(
425
+ model_group_override
426
+ )
422
427
 
423
428
 
424
429
  def get_loc_stats() -> str:
@@ -475,3 +480,132 @@ def copy_to_clipboard(text: str) -> None:
475
480
  )
476
481
  except Exception as e:
477
482
  PrettyOutput.print(f"使用xclip时出错: {e}", OutputType.WARNING)
483
+
484
+
485
+ def _pull_git_repo(repo_path: Path, repo_type: str):
486
+ """对指定的git仓库执行git pull操作,并根据commit hash判断是否有更新。"""
487
+ git_dir = repo_path / ".git"
488
+ if not git_dir.is_dir():
489
+ return
490
+
491
+ PrettyOutput.print(f"正在更新{repo_type}库 '{repo_path.name}'...", OutputType.INFO)
492
+ try:
493
+ # 检查是否有远程仓库
494
+ remote_result = subprocess.run(
495
+ ["git", "remote"],
496
+ cwd=repo_path,
497
+ capture_output=True,
498
+ text=True,
499
+ check=True,
500
+ timeout=10,
501
+ )
502
+ if not remote_result.stdout.strip():
503
+ PrettyOutput.print(
504
+ f"'{repo_path.name}' 未配置远程仓库,跳过更新。",
505
+ OutputType.INFO,
506
+ )
507
+ return
508
+
509
+ # 检查git仓库状态
510
+ status_result = subprocess.run(
511
+ ["git", "status", "--porcelain"],
512
+ cwd=repo_path,
513
+ capture_output=True,
514
+ text=True,
515
+ check=True,
516
+ timeout=10,
517
+ )
518
+ if status_result.stdout:
519
+ PrettyOutput.print(
520
+ f"检测到 '{repo_path.name}' 存在未提交的更改,跳过自动更新。",
521
+ OutputType.WARNING,
522
+ )
523
+ return
524
+
525
+ # 获取更新前的commit hash
526
+ before_hash_result = subprocess.run(
527
+ ["git", "rev-parse", "HEAD"],
528
+ cwd=repo_path,
529
+ capture_output=True,
530
+ text=True,
531
+ check=True,
532
+ timeout=10,
533
+ )
534
+ before_hash = before_hash_result.stdout.strip()
535
+
536
+ # 执行 git pull
537
+ pull_result = subprocess.run(
538
+ ["git", "pull"],
539
+ cwd=repo_path,
540
+ capture_output=True,
541
+ text=True,
542
+ check=True,
543
+ timeout=60,
544
+ )
545
+
546
+ # 获取更新后的commit hash
547
+ after_hash_result = subprocess.run(
548
+ ["git", "rev-parse", "HEAD"],
549
+ cwd=repo_path,
550
+ capture_output=True,
551
+ text=True,
552
+ check=True,
553
+ timeout=10,
554
+ )
555
+ after_hash = after_hash_result.stdout.strip()
556
+
557
+ if before_hash != after_hash:
558
+ PrettyOutput.print(f"{repo_type}库 '{repo_path.name}' 已更新。", OutputType.SUCCESS)
559
+ if pull_result.stdout.strip():
560
+ PrettyOutput.print(pull_result.stdout.strip(), OutputType.INFO)
561
+ else:
562
+ PrettyOutput.print(f"{repo_type}库 '{repo_path.name}' 已是最新版本。", OutputType.INFO)
563
+
564
+ except FileNotFoundError:
565
+ PrettyOutput.print(
566
+ f"git 命令未找到,跳过更新 '{repo_path.name}'。", OutputType.WARNING
567
+ )
568
+ except subprocess.TimeoutExpired:
569
+ PrettyOutput.print(f"更新 '{repo_path.name}' 超时。", OutputType.ERROR)
570
+ except subprocess.CalledProcessError as e:
571
+ error_message = e.stderr.strip() if e.stderr else str(e)
572
+ PrettyOutput.print(
573
+ f"更新 '{repo_path.name}' 失败: {error_message}", OutputType.ERROR
574
+ )
575
+ except Exception as e:
576
+ PrettyOutput.print(
577
+ f"更新 '{repo_path.name}' 时发生未知错误: {str(e)}", OutputType.ERROR
578
+ )
579
+
580
+
581
+ def daily_check_git_updates(repo_dirs: List[str], repo_type: str):
582
+ """
583
+ 对指定的目录列表执行每日一次的git更新检查。
584
+
585
+ Args:
586
+ repo_dirs (List[str]): 需要检查的git仓库目录列表。
587
+ repo_type (str): 仓库的类型名称,例如 "工具" 或 "方法论",用于日志输出。
588
+ """
589
+ data_dir = Path(get_data_dir())
590
+ last_check_file = data_dir / f"{repo_type}_updates_last_check.txt"
591
+ should_check_for_updates = True
592
+
593
+ if last_check_file.exists():
594
+ try:
595
+ last_check_timestamp = float(last_check_file.read_text())
596
+ last_check_date = datetime.fromtimestamp(last_check_timestamp).date()
597
+ if last_check_date == datetime.now().date():
598
+ should_check_for_updates = False
599
+ except (ValueError, IOError):
600
+ pass
601
+
602
+ if should_check_for_updates:
603
+ PrettyOutput.print(f"执行每日{repo_type}库更新检查...", OutputType.INFO)
604
+ for repo_dir in repo_dirs:
605
+ p_repo_dir = Path(repo_dir)
606
+ if p_repo_dir.exists() and p_repo_dir.is_dir():
607
+ _pull_git_repo(p_repo_dir, repo_type)
608
+ try:
609
+ last_check_file.write_text(str(time.time()))
610
+ except IOError as e:
611
+ PrettyOutput.print(f"无法写入git更新检查时间戳: {e}", OutputType.WARNING)
@@ -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 | 是否打印提示 |