mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
feat: add model alias overrides (#1262)
* feat: add model alias overrides Preserve user model overrides across provider catalog refreshes and resolve effective model metadata for runtime, TUI, protocol, and ACP consumers. * fix: apply model display name overrides Show overridden model display names in the footer, welcome panel, status output, and model switch confirmations. * fix: pass through kimi effort when undeclared Keep support_efforts authoritative when declared, but pass requested Kimi thinking effort through when the model does not declare support_efforts. * fix: honor model overrides in effort commands Use effective model metadata for /effort choices and for always_thinking clamping when resolving thinking effort.
This commit is contained in:
parent
0e279bfd7e
commit
c070fbedde
36 changed files with 750 additions and 91 deletions
|
|
@ -127,6 +127,8 @@ Each entry in the `models` table defines a model alias (the name used in `defaul
|
|||
| `max_context_size` | `integer` | Yes | Maximum context length in tokens; must be at least 1 |
|
||||
| `max_output_size` | `integer` | No | Per-request output token cap (maps to `max_tokens`). Currently only the `anthropic` provider honors it; recognized Claude models are automatically clamped to the server-side maximum |
|
||||
| `capabilities` | `array<string>` | No | Capability tags to add explicitly: `thinking`, `image_in`, `video_in`, `audio_in`, `tool_use`. Unioned with the capabilities auto-detected by the provider — entries can only be added, never removed |
|
||||
| `support_efforts` | `array<string>` | No | Thinking effort levels declared by the model catalog. Managed and open-platform refreshes may rewrite this field; to pin it manually, set `[models."<alias>".overrides] support_efforts` instead |
|
||||
| `default_effort` | `string` | No | Default thinking effort for the model. Managed and open-platform refreshes may rewrite this field; to pin it manually, set `[models."<alias>".overrides] default_effort` instead |
|
||||
| `display_name` | `string` | No | Name shown in the UI; falls back to `model` when unset |
|
||||
| `reasoning_key` | `string` | No | `openai` provider only. Override the field name used for reasoning content when the gateway returns it under a non-standard name; by default `reasoning_content`, `reasoning_details`, and `reasoning` are auto-detected |
|
||||
| `adaptive_thinking` | `boolean` | No | `anthropic` provider only. Force adaptive thinking on or off, overriding the version inference based on the model name. Omit to infer automatically (Claude ≥ 4.6 uses adaptive) |
|
||||
|
|
@ -140,6 +142,25 @@ model = "gpt-4.1"
|
|||
max_context_size = 1047576
|
||||
```
|
||||
|
||||
### Model overrides
|
||||
|
||||
Use `[models."<alias>".overrides]` for user overrides that must survive provider-model refreshes. Runtime consumers read the effective value: the override when present, otherwise the top-level field.
|
||||
|
||||
```toml
|
||||
[models."kimi-code/kimi-k2"]
|
||||
provider = "managed:kimi-code"
|
||||
model = "kimi-k2"
|
||||
max_context_size = 262144
|
||||
support_efforts = ["low", "high", "max"]
|
||||
default_effort = "max"
|
||||
|
||||
[models."kimi-code/kimi-k2".overrides]
|
||||
support_efforts = ["low", "high"]
|
||||
default_effort = "high"
|
||||
```
|
||||
|
||||
`[models."<alias>".overrides]` accepts ordinary model fields such as `max_context_size`, `max_output_size`, `capabilities`, `display_name`, `reasoning_key`, `adaptive_thinking`, `support_efforts`, and `default_effort`. It does not accept identity / routing fields: `provider`, `model`, `protocol`, and `beta_api`.
|
||||
|
||||
You can also switch models temporarily without touching the config file — by setting `KIMI_MODEL_*` environment variables, the CLI synthesizes a temporary provider in memory that does not persist after restart. See [Define a model from environment variables](./env-vars.md#define-a-model-from-environment-variables-kimi_model).
|
||||
|
||||
## `thinking`
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ KIMI_BASE_URL = "https://api.moonshot.ai/v1"
|
|||
| `max_context_size` | `integer` | 是 | 最大上下文长度(token 数),必须 ≥ 1 |
|
||||
| `max_output_size` | `integer` | 否 | 单次请求的输出 token 上限(对应 `max_tokens`)。目前仅 `anthropic` 供应商读取;已识别的 Claude 系列会自动限制在服务端允许的最大值内 |
|
||||
| `capabilities` | `array<string>` | 否 | 显式追加的能力标签:`thinking`、`image_in`、`video_in`、`audio_in`、`tool_use`。与供应商自动识别的能力取并集,只能追加不能移除 |
|
||||
| `support_efforts` | `array<string>` | 否 | 模型目录声明的 Thinking 档位。managed 和 open-platform 刷新可能会改写该字段;如需手动固定,请改用 `[models."<alias>".overrides] support_efforts` |
|
||||
| `default_effort` | `string` | 否 | 模型的默认 Thinking 档位。managed 和 open-platform 刷新可能会改写该字段;如需手动固定,请改用 `[models."<alias>".overrides] default_effort` |
|
||||
| `display_name` | `string` | 否 | UI 中显示的名称,未设时回退到 `model` |
|
||||
| `reasoning_key` | `string` | 否 | 仅 `openai` 供应商。当网关用非标准字段名返回推理内容时才需要设置;默认自动识别 `reasoning_content` / `reasoning_details` / `reasoning` |
|
||||
| `adaptive_thinking` | `boolean` | 否 | 仅 `anthropic` 供应商。强制开启或关闭 adaptive thinking,覆盖按模型名推断的逻辑。省略时自动推断(Claude ≥ 4.6 使用 adaptive) |
|
||||
|
|
@ -140,6 +142,25 @@ model = "gpt-4.1"
|
|||
max_context_size = 1047576
|
||||
```
|
||||
|
||||
### 模型覆盖项
|
||||
|
||||
如果某些用户覆盖需要在 provider-model 刷新后保留,请写到 `[models."<alias>".overrides]`。运行时读取的是 effective 值:有 override 时用 override,否则用顶层字段。
|
||||
|
||||
```toml
|
||||
[models."kimi-code/kimi-k2"]
|
||||
provider = "managed:kimi-code"
|
||||
model = "kimi-k2"
|
||||
max_context_size = 262144
|
||||
support_efforts = ["low", "high", "max"]
|
||||
default_effort = "max"
|
||||
|
||||
[models."kimi-code/kimi-k2".overrides]
|
||||
support_efforts = ["low", "high"]
|
||||
default_effort = "high"
|
||||
```
|
||||
|
||||
`[models."<alias>".overrides]` 接受普通模型字段,例如 `max_context_size`、`max_output_size`、`capabilities`、`display_name`、`reasoning_key`、`adaptive_thinking`、`support_efforts` 和 `default_effort`。不接受身份 / 路由字段:`provider`、`model`、`protocol` 和 `beta_api`。
|
||||
|
||||
无需修改配置文件也可以临时切换模型——通过 `KIMI_MODEL_*` 环境变量在内存里合成一个临时供应商,详见[用环境变量定义模型](./env-vars.md#用环境变量定义模型-kimi-model)。
|
||||
|
||||
## `thinking`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue