From e1d3ec21e593bb2c233bf26af95c4ce96f62bf21 Mon Sep 17 00:00:00 2001 From: chenchun Date: Mon, 28 Jul 2025 13:15:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/OpenAi/ThorChatCompletionsRequest.cs | 8 ++++---- .../Chats/AzureOpenAiChatCompletionCompletionsService.cs | 1 + .../Managers/AiGateWayManager.cs | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ThorChatCompletionsRequest.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ThorChatCompletionsRequest.cs index 4ed3bf96..fe84a991 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ThorChatCompletionsRequest.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/OpenAi/ThorChatCompletionsRequest.cs @@ -9,10 +9,10 @@ namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi; /// public class ThorChatCompletionsRequest { - public ThorChatCompletionsRequest() - { - Messages = new List(); - } + // public ThorChatCompletionsRequest() + // { + // Messages = new List(); + // } [JsonPropertyName("store")] public bool? Store { get; set; } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Chats/AzureOpenAiChatCompletionCompletionsService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Chats/AzureOpenAiChatCompletionCompletionsService.cs index 625421e1..a46c2ac6 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Chats/AzureOpenAiChatCompletionCompletionsService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiGateWay/Impl/ThorAzureOpenAI/Chats/AzureOpenAiChatCompletionCompletionsService.cs @@ -30,6 +30,7 @@ public class AzureOpenAiChatCompletionCompletionsService(ILogger= HttpStatusCode.BadRequest) { var error = await response.Content.ReadAsStringAsync(); + logger.LogError("Azure对话异常 , StatusCode: {StatusCode} 错误响应内容:{Content}", response.StatusCode, error); diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs index d1d28a83..4f9c3425 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/AiGateWayManager.cs @@ -119,7 +119,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = request.Messages.LastOrDefault().Content ?? string.Empty, + Content = request.Messages?.LastOrDefault().Content ?? string.Empty, ModelId = request.Model, TokenUsage = data.Usage, }); @@ -213,7 +213,7 @@ public class AiGateWayManager : DomainService catch (Exception e) { _logger.LogError(e, $"Ai对话异常"); - var errorContent = $"Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}"; + var errorContent = $"Ai异常,异常信息:\n当前Ai模型:{request.Model}\n异常信息:{e.Message}\n异常堆栈:{e}"; var model = new ThorChatCompletionsResponse() { Choices = new List() @@ -247,7 +247,7 @@ public class AiGateWayManager : DomainService await _aiMessageManager.CreateUserMessageAsync(userId.Value, sessionId, new MessageInputDto { - Content = request.Messages.LastOrDefault()?.Content ?? string.Empty, + Content = request.Messages?.LastOrDefault()?.Content ?? string.Empty, ModelId = request.Model, TokenUsage = tokenUsage, });