diff --git a/src/Oms.Application/Dtos/Ai/AiDtos.cs b/src/Oms.Application/Dtos/Ai/AiDtos.cs
index 7cb0f98..b217d5d 100644
--- a/src/Oms.Application/Dtos/Ai/AiDtos.cs
+++ b/src/Oms.Application/Dtos/Ai/AiDtos.cs
@@ -16,6 +16,9 @@ public class AiProviderOutput
public string? ApiKey { get; set; }
+ ///
+ /// 默认模型名(历史字段名 ApiSecret,实际不当密钥脱敏)。
+ ///
public string? ApiSecret { get; set; }
public bool IsDefault { get; set; }
@@ -39,6 +42,9 @@ public class AiProviderSaveInput
public string? ApiKey { get; set; }
+ ///
+ /// 默认文字模型 ID;空表示保持原值。
+ ///
public string? ApiSecret { get; set; }
public bool IsDefault { get; set; }
diff --git a/src/Oms.Application/Services/Ai/AiService.cs b/src/Oms.Application/Services/Ai/AiService.cs
index cc9ecbd..d8f804a 100644
--- a/src/Oms.Application/Services/Ai/AiService.cs
+++ b/src/Oms.Application/Services/Ai/AiService.cs
@@ -127,7 +127,8 @@ public class AiService : ApplicationService
DisplayName = entity.DisplayName,
BaseUrl = entity.BaseUrl,
ApiKey = maskSecret ? MaskSecret(entity.ApiKeyEnc) : entity.ApiKeyEnc,
- ApiSecret = maskSecret ? MaskSecret(entity.ApiSecretEnc) : entity.ApiSecretEnc,
+ // ApiSecret 实际承载默认模型名,列表需明文回传以便卡片展示/编辑
+ ApiSecret = entity.ApiSecretEnc,
IsDefault = entity.IsDefault,
Enabled = entity.Enabled
};
diff --git a/src/Oms.Application/Shared/AiLlmClient.cs b/src/Oms.Application/Shared/AiLlmClient.cs
index 6f9f825..0400994 100644
--- a/src/Oms.Application/Shared/AiLlmClient.cs
+++ b/src/Oms.Application/Shared/AiLlmClient.cs
@@ -82,6 +82,10 @@ public class AiLlmClient
var model = modelOverride ?? provider.ApiSecretEnc;
if (string.IsNullOrWhiteSpace(model))
+ {
+ model = DefaultModelForProviderType(provider.ProviderType);
+ }
+ if (string.IsNullOrWhiteSpace(model))
{
throw new BusinessException($"请先配置 {provider.DisplayName} 的模型名(ApiSecret 字段)或在请求中传入 model");
}
@@ -256,6 +260,19 @@ public class AiLlmClient
return body.Length <= 300 ? body : body[..300];
}
+
+ ///
+ /// 未配置 ApiSecret(模型名)时按提供商类型回落默认模型。
+ ///
+ private static string? DefaultModelForProviderType(string? providerType) =>
+ (providerType ?? string.Empty).Trim().ToLowerInvariant() switch
+ {
+ "chatgpt" => "gpt-4o-mini",
+ "doubao" => "doubao-1-5-pro-32k-250115",
+ "deepseek" => "deepseek-chat",
+ "zhipu" => "glm-5.1",
+ _ => null
+ };
}
public static class AiLlmServiceExtensions