Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,38 @@ custom provider 通过单独文件声明,而不是写进 `config.yaml`:
name: company-gateway
driver: openaicompat
api_key_env: COMPANY_GATEWAY_API_KEY
model_source: discover
openai_compatible:
base_url: https://llm.example.com/v1
api_style: chat_completions
```

`model_source` 语义如下:

- `discover`(默认):通过 discovery(如 `/models`)拉取模型列表。
- `manual`:不触发 discovery,优先使用 `models` 中声明的模型列表。

`manual` 模式示例:

```yaml
name: company-gateway-manual
driver: openaicompat
api_key_env: COMPANY_GATEWAY_API_KEY
model_source: manual
openai_compatible:
base_url: https://llm.example.com/v1
models:
- id: gpt-4o-mini
name: GPT-4o Mini
context_window: 128000
```

迁移与兼容性说明:

- 老配置未声明 `model_source` 时,默认按 `discover` 处理。
- `manual` 模式下必须提供 `models`,否则会在加载/创建阶段报错。
- `manual` 模式会忽略 discovery 相关字段(如 `discovery_endpoint_path`、`discovery_response_profile`)。

## Auto Compact 失败与校验补充

- 当 `context.auto_compact.input_token_threshold <= 0` 时,如果当前 provider 选择无效、catalog snapshot 查询失败、模型缺少可用的 `ContextWindow`,或 `ContextWindow <= reserve_tokens`,系统会回退到 `fallback_input_token_threshold`,不会静默关闭 auto compact。
Expand Down
6 changes: 3 additions & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ func TestProviderConfigResolveAPIKey(t *testing.T) {
}{
{
name: "success",
envKey: "OPENAI_API_KEY",
envKey: "NEOCODE_TEST_API_KEY_SUCCESS",
envValue: "secret-value",
},
{
name: "missing",
envKey: "OPENAI_API_KEY",
expectErr: "environment variable OPENAI_API_KEY is empty",
envKey: "NEOCODE_TEST_API_KEY_MISSING",
expectErr: "environment variable NEOCODE_TEST_API_KEY_MISSING is empty",
},
}

Expand Down
Loading
Loading