fix vector collection data issue
This commit is contained in:
parent
12077f0ebf
commit
d27e8fadf6
|
|
@ -3,8 +3,8 @@ namespace BotSharp.Abstraction.VectorStorage.Models;
|
||||||
public class VectorCollectionData
|
public class VectorCollectionData
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public Dictionary<string, VectorPayloadValue> Data { get; set; } = new();
|
public Dictionary<string, VectorPayloadValue> Payload { get; set; } = new();
|
||||||
public Dictionary<string, object> Payload => Data?.ToDictionary(x => x.Key, x => x.Value.DataValue) ?? [];
|
public Dictionary<string, object> Data => Payload?.ToDictionary(x => x.Key, x => x.Value.DataValue) ?? [];
|
||||||
public double? Score { get; set; }
|
public double? Score { get; set; }
|
||||||
|
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class VectorSearchResult : VectorCollectionData
|
||||||
return new VectorSearchResult
|
return new VectorSearchResult
|
||||||
{
|
{
|
||||||
Id = data.Id,
|
Id = data.Id,
|
||||||
Data = data.Data,
|
Payload = data.Payload,
|
||||||
Score = data.Score,
|
Score = data.Score,
|
||||||
Vector = data.Vector
|
Vector = data.Vector
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ public class VectorKnowledgeViewModel
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("data")]
|
|
||||||
public IDictionary<string, VectorPayloadValue> Data { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("payload")]
|
[JsonPropertyName("payload")]
|
||||||
public IDictionary<string, object> Payload { get; set; }
|
public IDictionary<string, VectorPayloadValue> Payload { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("data")]
|
||||||
|
public IDictionary<string, object> Data { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("score")]
|
[JsonPropertyName("score")]
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class MemoryVectorDb : IVectorDb
|
||||||
.Take(options.Limit.GetValueOrDefault())
|
.Take(options.Limit.GetValueOrDefault())
|
||||||
.Select(i => new VectorCollectionData
|
.Select(i => new VectorCollectionData
|
||||||
{
|
{
|
||||||
Data = new Dictionary<string, VectorPayloadValue>
|
Payload = new Dictionary<string, VectorPayloadValue>
|
||||||
{
|
{
|
||||||
{ "text", new(_vectors[collectionName][i].Text, VectorPayloadDataType.String) }
|
{ "text", new(_vectors[collectionName][i].Text, VectorPayloadDataType.String) }
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ public class QdrantDb : IVectorDb
|
||||||
var points = response?.Result?.Select(x => new VectorCollectionData
|
var points = response?.Result?.Select(x => new VectorCollectionData
|
||||||
{
|
{
|
||||||
Id = x.Id?.Uuid ?? string.Empty,
|
Id = x.Id?.Uuid ?? string.Empty,
|
||||||
Data = MapPayload(x.Payload),
|
Payload = MapPayload(x.Payload),
|
||||||
Vector = filter.WithVector ? x.Vectors?.Vector?.Data?.ToArray() : null
|
Vector = filter.WithVector ? x.Vectors?.Vector?.Data?.ToArray() : null
|
||||||
})?.ToList() ?? new List<VectorCollectionData>();
|
})?.ToList() ?? new List<VectorCollectionData>();
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ public class QdrantDb : IVectorDb
|
||||||
return points.Select(x => new VectorCollectionData
|
return points.Select(x => new VectorCollectionData
|
||||||
{
|
{
|
||||||
Id = x.Id?.Uuid ?? string.Empty,
|
Id = x.Id?.Uuid ?? string.Empty,
|
||||||
Data = MapPayload(x.Payload),
|
Payload = MapPayload(x.Payload),
|
||||||
Vector = x.Vectors?.Vector?.Data?.ToArray()
|
Vector = x.Vectors?.Vector?.Data?.ToArray()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +294,7 @@ public class QdrantDb : IVectorDb
|
||||||
results = points.Select(x => new VectorCollectionData
|
results = points.Select(x => new VectorCollectionData
|
||||||
{
|
{
|
||||||
Id = x.Id.Uuid,
|
Id = x.Id.Uuid,
|
||||||
Data = MapPayload(x.Payload),
|
Payload = MapPayload(x.Payload),
|
||||||
Score = x.Score,
|
Score = x.Score,
|
||||||
Vector = x.Vectors?.Vector?.Data?.ToArray()
|
Vector = x.Vectors?.Vector?.Data?.ToArray()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ namespace BotSharp.Plugin.SemanticKernel
|
||||||
{
|
{
|
||||||
resultTexts.Add(new VectorCollectionData
|
resultTexts.Add(new VectorCollectionData
|
||||||
{
|
{
|
||||||
Data = new Dictionary<string, VectorPayloadValue>
|
Payload = new Dictionary<string, VectorPayloadValue>
|
||||||
{
|
{
|
||||||
{ "text", new(record.Metadata.Text, VectorPayloadDataType.String) }
|
{ "text", new(record.Metadata.Text, VectorPayloadDataType.String) }
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue