fix: 修正 yi- 模型前缀截取逻辑错误
统一将模型 ID 和请求 Model 的前缀去除逻辑由错误的尾部截取改为正确的从索引 3 开始截取,避免模型名称被截断导致调用异常
This commit is contained in:
@@ -96,7 +96,7 @@ public class AiGateWayManager : DomainService
|
|||||||
if (!string.IsNullOrEmpty(aiModelDescribe.ModelId) &&
|
if (!string.IsNullOrEmpty(aiModelDescribe.ModelId) &&
|
||||||
aiModelDescribe.ModelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
aiModelDescribe.ModelId.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
aiModelDescribe.ModelId = aiModelDescribe.ModelId[^3..];
|
aiModelDescribe.ModelId = aiModelDescribe.ModelId[3..];
|
||||||
}
|
}
|
||||||
return aiModelDescribe;
|
return aiModelDescribe;
|
||||||
}
|
}
|
||||||
@@ -518,7 +518,11 @@ public class AiGateWayManager : DomainService
|
|||||||
var chatService =
|
var chatService =
|
||||||
LazyServiceProvider.GetRequiredKeyedService<IAnthropicChatCompletionService>(modelDescribe.HandlerName);
|
LazyServiceProvider.GetRequiredKeyedService<IAnthropicChatCompletionService>(modelDescribe.HandlerName);
|
||||||
var data = await chatService.ChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
var data = await chatService.ChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
||||||
|
if (!string.IsNullOrEmpty(request.Model) &&
|
||||||
|
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
request.Model = request.Model[3..];
|
||||||
|
}
|
||||||
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
data.SupplementalMultiplier(modelDescribe.Multiplier);
|
||||||
|
|
||||||
if (userId is not null)
|
if (userId is not null)
|
||||||
@@ -585,7 +589,7 @@ public class AiGateWayManager : DomainService
|
|||||||
if (!string.IsNullOrEmpty(request.Model) &&
|
if (!string.IsNullOrEmpty(request.Model) &&
|
||||||
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
request.Model.StartsWith("yi-", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
request.Model = request.Model[^3..];
|
request.Model = request.Model[3..];
|
||||||
}
|
}
|
||||||
|
|
||||||
var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
var completeChatResponse = chatService.StreamChatCompletionsAsync(modelDescribe, request, cancellationToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user