mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-07 03:34:20 +08:00
fix(opencode): preserve extra model fields during serialization
Add `extra` field with serde flatten to OpenCodeModel struct to capture custom fields like cost, modalities, thinking, and variants that were previously lost during save operations.
This commit is contained in:
@@ -596,6 +596,11 @@ pub struct OpenCodeModel {
|
||||
/// 模型额外选项(provider 路由等)
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub options: Option<HashMap<String, Value>>,
|
||||
|
||||
/// 额外字段(cost、modalities、thinking、variants 等)
|
||||
/// 使用 flatten 捕获所有未明确定义的字段
|
||||
#[serde(flatten, default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub extra: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
/// OpenCode 模型限制
|
||||
|
||||
@@ -310,6 +310,8 @@ export interface OpenCodeModel {
|
||||
output?: number;
|
||||
};
|
||||
options?: Record<string, unknown>; // 模型级别额外选项(provider 路由等)
|
||||
// 支持任意额外字段(cost、modalities、thinking、variants 等)
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// OpenCode 供应商选项
|
||||
|
||||
Reference in New Issue
Block a user