diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/Embeddings/ThorEmbeddingInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/Embeddings/ThorEmbeddingInput.cs index 9d854ead..82838d23 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/Embeddings/ThorEmbeddingInput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Dtos/OpenAi/Embeddings/ThorEmbeddingInput.cs @@ -11,7 +11,7 @@ public sealed class ThorEmbeddingInput public object Input { get; set; } [JsonPropertyName("encoding_format")] - public string EncodingFormat { get; set; } + public string? EncodingFormat { get; set; } [JsonPropertyName("dimensions")] public int? Dimensions { get; set; } 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 c451c43d..31eca5c8 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 @@ -360,11 +360,7 @@ public class AiGateWayManager : DomainService //dto进行转换,支持多种格式 if (input.Input is JsonElement str) { - if (str.ValueKind == JsonValueKind.String) - { - embeddingCreateRequest.Input = str.ToString(); - } - else if (str.ValueKind == JsonValueKind.Array) + if (str.ValueKind == JsonValueKind.Array) { var inputString = str.EnumerateArray().Select(x => x.ToString()).ToArray(); embeddingCreateRequest.InputAsList = inputString.ToList(); @@ -374,6 +370,10 @@ public class AiGateWayManager : DomainService throw new Exception("Input,输入格式错误,非string或Array类型"); } } + else if (input.Input is string strInput) + { + embeddingCreateRequest.Input = strInput; + } else { throw new Exception("Input,输入格式错误,未找到类型"); @@ -398,21 +398,22 @@ public class AiGateWayManager : DomainService Usage = usage }); - await _aiMessageManager.CreateUserMessageAsync(userId, sessionId, - new MessageInputDto - { - Content = string.Empty, - ModelId = input.Model, - TokenUsage = usage, - }); - - await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, - new MessageInputDto - { - Content = string.Empty, - ModelId = input.Model, - TokenUsage = usage - }); + //知识库暂不使用message统计 + // await _aiMessageManager.CreateUserMessageAsync(userId, sessionId, + // new MessageInputDto + // { + // Content = string.Empty, + // ModelId = input.Model, + // TokenUsage = usage, + // }); + // + // await _aiMessageManager.CreateSystemMessageAsync(userId, sessionId, + // new MessageInputDto + // { + // Content = string.Empty, + // ModelId = input.Model, + // TokenUsage = usage + // }); await _usageStatisticsManager.SetUsageAsync(userId, input.Model, usage); }