2024-08-15 23:19:10 +00:00
|
|
|
using BotSharp.Abstraction.VectorStorage.Models;
|
2024-08-15 03:46:01 +00:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.OpenAPI.ViewModels.Knowledges;
|
|
|
|
|
|
2024-08-15 23:19:10 +00:00
|
|
|
public class VectorKnowledgeViewModel
|
2024-08-15 03:46:01 +00:00
|
|
|
{
|
|
|
|
|
[JsonPropertyName("id")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("data")]
|
2024-09-29 01:00:35 +00:00
|
|
|
public IDictionary<string, object> Data { get; set; }
|
2024-08-15 03:46:01 +00:00
|
|
|
|
|
|
|
|
[JsonPropertyName("score")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
public double? Score { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("vector")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
public float[]? Vector { get; set; }
|
|
|
|
|
|
|
|
|
|
|
2024-08-15 23:19:10 +00:00
|
|
|
public static VectorKnowledgeViewModel From(VectorSearchResult result)
|
2024-08-15 03:46:01 +00:00
|
|
|
{
|
2024-08-15 23:19:10 +00:00
|
|
|
return new VectorKnowledgeViewModel
|
2024-08-15 03:46:01 +00:00
|
|
|
{
|
|
|
|
|
Id = result.Id,
|
|
|
|
|
Data = result.Data,
|
|
|
|
|
Score = result.Score,
|
|
|
|
|
Vector = result.Vector
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-08-06 22:40:47 +00:00
|
|
|
|
|
|
|
|
public static VectorKnowledgeViewModel From(VectorCollectionData data)
|
|
|
|
|
{
|
|
|
|
|
return new VectorKnowledgeViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = data.Id,
|
|
|
|
|
Data = data.Data,
|
|
|
|
|
Vector = data.Vector
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-08-15 03:46:01 +00:00
|
|
|
}
|