Files
Yi.Admin/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Consts/ModelConst.cs
ccnetcore bd5cf30349 refactor: 统一模型前缀处理并规范网关层逻辑
- 抽取并统一使用 ModelConst 处理模型前缀,移除重复的 yi- 前缀判断代码
- 网关层模型 ID 规范化逻辑集中,提升可维护性
- 修复常量文件缺失换行问题
- 前端版本号调整为 3.7.1
2026-02-13 18:35:36 +08:00

48 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Yi.Framework.AiHub.Domain.Shared.Consts;
public class ModelConst
{
/// <summary>
/// 需要移除的模型前缀列表
/// </summary>
private static readonly List<string> ModelPrefixesToRemove =
[
"yi-",
"ma-"
];
/// <summary>
/// 获取模型ID的前缀如果存在
/// </summary>
private static string? GetModelPrefix(string? modelId)
{
if (string.IsNullOrEmpty(modelId)) return null;
return ModelPrefixesToRemove.FirstOrDefault(prefix =>
modelId!.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
}
/// <summary>
/// 移除模型ID的前缀返回标准模型ID
/// </summary>
public static string RemoveModelPrefix(string? modelId)
{
if (string.IsNullOrEmpty(modelId)) return string.Empty;
var prefix = GetModelPrefix(modelId);
if (prefix != null)
{
return modelId[prefix.Length..];
}
return modelId;
}
/// <summary>
/// 处理模型ID如有前缀则移除并返回新字符串
/// </summary>
public static string ProcessModelId(string? modelId)
{
return RemoveModelPrefix(modelId);
}
}