From 64d04996af571b1ae44537bea0401599c65177af Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Wed, 25 Jun 2025 00:23:00 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96sse=E6=B5=81=E5=BC=8F?= =?UTF-8?q?=E4=BC=A0=E8=BE=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AiChat/Impl/AzureRestChatService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs index 1d6328ae..502eae48 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs @@ -55,10 +55,15 @@ public class AzureRestChatService : IChatService // 设置请求头 httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {_options.ApiKey}"); // 其他头信息如Content-Type在StringContent中设置 + + // 构造 POST 请求 + var request = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var content = new StringContent(jsonBody, Encoding.UTF8, "application/json"); + // 设置请求内容(示例) + request.Content =new StringContent(jsonBody, Encoding.UTF8, "application/json"); + // 发送POST请求 - HttpResponseMessage response = await httpClient.PostAsync(apiUrl, content, cancellationToken); + HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); // 确认响应成功 response.EnsureSuccessStatusCode();