feat: add group name functionality to models

- Introduced a new `group_name` field in the model configuration to allow for custom provider-group display names.
- Updated the `CursorModelCards`, `CursorModelEditor`, and `CursorSettingsPage` components to support group settings.
- Enhanced the UI to include group settings options, allowing users to modify group names and associated configurations.
- Added localization strings for new group settings features in both English and Chinese.
- Implemented a database migration to add the `group_name` column to the model configurations.
This commit is contained in:
leookun committed 2026-08-30 23:28:05 +08:00
1 parent 76baa3b0e7
commit e7a1cca4c6
32 files changed
+1950 -137

No files matched your search

+11
View File
@@ -87,6 +87,9 @@ pub struct ModelConfigInput {
#[serde(default)]
pub sort_order: i64,
pub display_name: String,
/// 供应商分组的自定义显示名;同一 base_url 主机下的模型共享。
#[serde(default)]
pub group_name: Option<String>,
#[serde(rename = "type")]
pub model_type: ModelType,
pub base_url: String,
@@ -124,6 +127,7 @@ pub struct ModelConfig {
pub model_hash: String,
pub sort_order: i64,
pub display_name: String,
pub group_name: Option<String>,
#[serde(rename = "type")]
pub model_type: ModelType,
pub base_url: String,
@@ -204,6 +208,12 @@ impl ModelConfig {
pub fn normalize_model_input(input: &ModelConfigInput) -> Result<ModelConfigInput> {
let display_name = required(&input.display_name, "model display name")?;
let group_name = input
.group_name
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.map(String::from);
let base_url = normalize_request_url(&input.base_url)?;
let api_key = required(&input.api_key, "model API key")?;
let tooltip_data = required(&input.tooltip_data, "model tooltip")?;
@@ -230,6 +240,7 @@ pub fn normalize_model_input(input: &ModelConfigInput) -> Result<ModelConfigInpu
let normalized = ModelConfigInput {
sort_order: input.sort_order.max(0),
display_name,
group_name,
model_type: input.model_type,
base_url,
use_full_url: input.use_full_url,