fix: 修复Embedding输入处理逻辑和字段可空性
- 优化Embedding输入类型判断逻辑,支持string和JsonElement数组类型 - 将EncodingFormat字段设置为可空类型,提高兼容性 - 注释知识库场景下的消息统计功能,避免不必要的数据记录
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user