feat: 完成ai-hub第一期功能
This commit is contained in:
@@ -1,28 +1,24 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Azure;
|
||||
using Azure.AI.OpenAI;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenAI.Chat;
|
||||
using Yi.Framework.AiHub.Application.Contracts.Options;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.AiChat.Impl;
|
||||
|
||||
public class AzureChatService : IChatService
|
||||
{
|
||||
private readonly AiChatModelOptions _options;
|
||||
|
||||
public AzureChatService(IOptions<AiGateWayOptions> options)
|
||||
public AzureChatService()
|
||||
{
|
||||
this._options = options.Value.Chats[nameof(AzureChatService)];
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<string> CompleteChatAsync(string modelId, List<ChatMessage> messages,
|
||||
public async IAsyncEnumerable<string> CompleteChatAsync(AiModelDescribe aiModelDescribe, List<ChatMessage> messages,
|
||||
[EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
var endpoint = new Uri(_options.Endpoint);
|
||||
var endpoint = new Uri(aiModelDescribe.Endpoint);
|
||||
|
||||
var deploymentName = modelId;
|
||||
var apiKey = _options.ApiKey;
|
||||
var deploymentName = aiModelDescribe.ModelId;
|
||||
var apiKey = aiModelDescribe.ApiKey;
|
||||
|
||||
AzureOpenAIClient azureClient = new(
|
||||
endpoint,
|
||||
|
||||
Reference in New Issue
Block a user