feat: 完成ai网关搭建

This commit is contained in:
ccnetcore
2025-06-21 01:41:05 +08:00
parent 3b74dfd49a
commit 29985e2118
4 changed files with 18 additions and 10 deletions

View File

@@ -18,16 +18,18 @@ public class AiGateWayManager : DomainService
this._options = options.Value;
}
public IAsyncEnumerable<string> CompleteChatAsync(string modelId, List<ChatMessage> messages)
public IAsyncEnumerable<string> CompleteChatAsync(string modelId, List<ChatMessage> messages,
CancellationToken cancellationToken)
{
foreach (var chat in _options.Chats)
{
if (chat.Value.ModelIds.Contains(modelId))
{
var chatService = LazyServiceProvider.GetRequiredKeyedService<IChatService>(chat.Key);
return chatService.CompleteChatAsync(modelId, messages);
return chatService.CompleteChatAsync(modelId, messages, cancellationToken);
}
}
throw new UserFriendlyException($"当前暂不支持该模型-【{modelId}】");
}
}