feat: 完成ai网关搭建
This commit is contained in:
@@ -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}】");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user