mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-25 02:46:39 +08:00
feat: 新增向量嵌入服务支持
新增SiliconFlow向量嵌入服务实现,支持文本向量化功能: - 新增ITextEmbeddingService接口和SiliconFlowTextEmbeddingService实现 - 新增EmbeddingCreateRequest/Response等向量相关DTO - 在AiGateWayManager中新增EmbeddingForStatisticsAsync方法 - 在OpenApiService中新增向量生成API接口 - 扩展ModelTypeEnum枚举支持Embedding类型 - 优化ThorChatMessage的Content属性处理逻辑
This commit is contained in:
@@ -14,7 +14,6 @@ public class ThorChatMessage
|
||||
/// </summary>
|
||||
public ThorChatMessage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,20 +73,19 @@ public class ThorChatMessage
|
||||
{
|
||||
if (value is JsonElement str)
|
||||
{
|
||||
if (str.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
Content = value?.ToString();
|
||||
}
|
||||
else if (str.ValueKind == JsonValueKind.Array)
|
||||
if (str.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
Contents = JsonSerializer.Deserialize<IList<ThorChatMessageContent>>(value?.ToString());
|
||||
}
|
||||
}
|
||||
else if (value is string strInput)
|
||||
{
|
||||
Content = strInput;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = value?.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,15 +106,14 @@ public class ThorChatMessage
|
||||
/// </summary>
|
||||
[JsonPropertyName("function_call")]
|
||||
public ThorChatMessageFunction? FunctionCall { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 【可选】推理内容
|
||||
/// </summary>
|
||||
[JsonPropertyName("reasoning_content")]
|
||||
public string? ReasoningContent { get; set; }
|
||||
|
||||
[JsonPropertyName("id")]
|
||||
public string? Id { get; set; }
|
||||
|
||||
[JsonPropertyName("id")] public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工具调用列表,模型生成的工具调用,例如函数调用。<br/>
|
||||
@@ -164,14 +161,15 @@ public class ThorChatMessage
|
||||
/// <param name="name">参与者的可选名称。提供模型信息以区分同一角色的参与者。</param>
|
||||
/// <param name="toolCalls">工具调用参数列表</param>
|
||||
/// <returns></returns>
|
||||
public static ThorChatMessage CreateAssistantMessage(string content, string? name = null, List<ThorToolCall> toolCalls = null)
|
||||
public static ThorChatMessage CreateAssistantMessage(string content, string? name = null,
|
||||
List<ThorToolCall> toolCalls = null)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Role = ThorChatMessageRoleConst.Assistant,
|
||||
Content = content,
|
||||
Name = name,
|
||||
ToolCalls=toolCalls,
|
||||
ToolCalls = toolCalls,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -187,7 +185,7 @@ public class ThorChatMessage
|
||||
{
|
||||
Role = ThorChatMessageRoleConst.Tool,
|
||||
Content = content,
|
||||
ToolCallId= toolCallId
|
||||
ToolCallId = toolCallId
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user