Compare commits

..

1 Commits

Author SHA1 Message Date
YoVinchen a052af0060 style: format code and apply clippy lint fixes 2026-02-06 15:08:07 +08:00
5 changed files with 11 additions and 56 deletions
+10 -47
View File
@@ -919,16 +919,7 @@ impl Database {
/// 注意: model_id 使用短横线格式(如 claude-haiku-4-5),与 API 返回的模型名称标准化后一致 /// 注意: model_id 使用短横线格式(如 claude-haiku-4-5),与 API 返回的模型名称标准化后一致
fn seed_model_pricing(conn: &Connection) -> Result<(), AppError> { fn seed_model_pricing(conn: &Connection) -> Result<(), AppError> {
let pricing_data = [ let pricing_data = [
// Claude 4.6 系列 // Claude 4.5 系列 (Latest Models)
(
"claude-opus-4-6-20260206",
"Claude Opus 4.6",
"5",
"25",
"0.50",
"6.25",
),
// Claude 4.5 系列
( (
"claude-opus-4-5-20251101", "claude-opus-4-5-20251101",
"Claude Opus 4.5", "Claude Opus 4.5",
@@ -1034,40 +1025,6 @@ impl Database {
"0.175", "0.175",
"0", "0",
), ),
// GPT-5.3 Codex 系列
("gpt-5.3-codex", "GPT-5.3 Codex", "1.75", "14", "0.175", "0"),
(
"gpt-5.3-codex-low",
"GPT-5.3 Codex",
"1.75",
"14",
"0.175",
"0",
),
(
"gpt-5.3-codex-medium",
"GPT-5.3 Codex",
"1.75",
"14",
"0.175",
"0",
),
(
"gpt-5.3-codex-high",
"GPT-5.3 Codex",
"1.75",
"14",
"0.175",
"0",
),
(
"gpt-5.3-codex-xhigh",
"GPT-5.3 Codex",
"1.75",
"14",
"0.175",
"0",
),
// GPT-5.1 系列 // GPT-5.1 系列
("gpt-5.1", "GPT-5.1", "1.25", "10", "0.125", "0"), ("gpt-5.1", "GPT-5.1", "1.25", "10", "0.125", "0"),
("gpt-5.1-low", "GPT-5.1", "1.25", "10", "0.125", "0"), ("gpt-5.1-low", "GPT-5.1", "1.25", "10", "0.125", "0"),
@@ -1255,7 +1212,7 @@ impl Database {
for (model_id, display_name, input, output, cache_read, cache_creation) in pricing_data { for (model_id, display_name, input, output, cache_read, cache_creation) in pricing_data {
conn.execute( conn.execute(
"INSERT OR IGNORE INTO model_pricing ( "INSERT OR REPLACE INTO model_pricing (
model_id, display_name, input_cost_per_million, output_cost_per_million, model_id, display_name, input_cost_per_million, output_cost_per_million,
cache_read_cost_per_million, cache_creation_cost_per_million cache_read_cost_per_million, cache_creation_cost_per_million
) VALUES (?1, ?2, ?3, ?4, ?5, ?6)", ) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
@@ -1282,8 +1239,14 @@ impl Database {
} }
fn ensure_model_pricing_seeded_on_conn(conn: &Connection) -> Result<(), AppError> { fn ensure_model_pricing_seeded_on_conn(conn: &Connection) -> Result<(), AppError> {
// 每次启动都执行 INSERT OR IGNORE,增量追加新模型,已有数据不覆盖 let count: i64 = conn
Self::seed_model_pricing(conn) .query_row("SELECT COUNT(*) FROM model_pricing", [], |row| row.get(0))
.map_err(|e| AppError::Database(format!("统计模型定价数据失败: {e}")))?;
if count == 0 {
Self::seed_model_pricing(conn)?;
}
Ok(())
} }
// --- 辅助方法 --- // --- 辅助方法 ---
@@ -746,7 +746,7 @@ export function ProviderForm({
return; return;
} }
// OpenCode: validate provider key and models // OpenCode: validate provider key
if (appId === "opencode") { if (appId === "opencode") {
const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/; const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
if (!opencodeProviderKey.trim()) { if (!opencodeProviderKey.trim()) {
@@ -761,11 +761,6 @@ export function ProviderForm({
toast.error(t("opencode.providerKeyDuplicate")); toast.error(t("opencode.providerKeyDuplicate"));
return; return;
} }
// Validate that at least one model is configured
if (Object.keys(opencodeModels).length === 0) {
toast.error(t("opencode.modelsRequired"));
return;
}
} }
// 非官方供应商必填校验:端点和 API Key // 非官方供应商必填校验:端点和 API Key
-1
View File
@@ -633,7 +633,6 @@
"modelId": "Model ID", "modelId": "Model ID",
"modelName": "Display Name", "modelName": "Display Name",
"noModels": "No models configured", "noModels": "No models configured",
"modelsRequired": "Please add at least one model",
"providerKey": "Provider Key", "providerKey": "Provider Key",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "Unique identifier in config file. Cannot be changed after creation. Use lowercase letters, numbers, and hyphens only.", "providerKeyHint": "Unique identifier in config file. Cannot be changed after creation. Use lowercase letters, numbers, and hyphens only.",
-1
View File
@@ -633,7 +633,6 @@
"modelId": "モデル ID", "modelId": "モデル ID",
"modelName": "表示名", "modelName": "表示名",
"noModels": "モデルが設定されていません", "noModels": "モデルが設定されていません",
"modelsRequired": "モデルを少なくとも1つ追加してください",
"providerKey": "プロバイダーキー", "providerKey": "プロバイダーキー",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "設定ファイルの一意の識別子。作成後は変更できません。小文字、数字、ハイフンのみ使用できます。", "providerKeyHint": "設定ファイルの一意の識別子。作成後は変更できません。小文字、数字、ハイフンのみ使用できます。",
-1
View File
@@ -633,7 +633,6 @@
"modelId": "模型 ID", "modelId": "模型 ID",
"modelName": "显示名称", "modelName": "显示名称",
"noModels": "暂无模型配置", "noModels": "暂无模型配置",
"modelsRequired": "请至少添加一个模型配置",
"providerKey": "供应商标识", "providerKey": "供应商标识",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "配置文件中的唯一标识符,创建后无法修改,只能使用小写字母、数字和连字符", "providerKeyHint": "配置文件中的唯一标识符,创建后无法修改,只能使用小写字母、数字和连字符",