feat: 完成ai网关改造

This commit is contained in:
ccnetcore
2025-06-25 22:41:32 +08:00
parent 695aaedfba
commit c5037ea397
5 changed files with 32 additions and 31 deletions

View File

@@ -25,7 +25,10 @@ public class AzureChatService : IChatService
new AzureKeyCredential(apiKey));
ChatClient chatClient = azureClient.GetChatClient(deploymentName);
var response = chatClient.CompleteChatStreamingAsync(messages, cancellationToken: cancellationToken);
var response = chatClient.CompleteChatStreamingAsync(messages, new ChatCompletionOptions()
{
MaxOutputTokenCount = 2048
}, cancellationToken: cancellationToken);
await foreach (StreamingChatCompletionUpdate update in response)
{

View File

@@ -19,14 +19,6 @@ public class AzureRestChatService : IChatService
{
// 设置API URL
var apiUrl = $"{aiModelDescribe.Endpoint}models/chat/completions";
var ss = messages.Select(x => new
{
role = x.GetRoleAsString(),
content = x.Content.FirstOrDefault()?.Text
}).ToList();
// 准备请求内容
var requestBody = new
{