Persist Vector Storage and Prefix-Scoped Vector Search
- Add IXAiDataProvider contracts for batch upsert, prefix search, loading, and removal; - Persist chunks in existing XAiVector schema without migration; - Support topK, minimum score, prefix filtering, batch persistence, and replacement. Files: M Interfaces/IXAiDataProvider.cs; M Providers/XAiDataProvider.cs
This commit is contained in:
@@ -298,5 +298,77 @@ namespace xAiModels.Interfaces
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Vectors ...
|
||||
/// <summary>
|
||||
/// Insert or Update a Single Vector (Matched by Identifier) ...
|
||||
/// </summary>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="embedding"></param>
|
||||
/// <param name="metadata"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task UpsertVectorAsync(
|
||||
string identifier,
|
||||
string text,
|
||||
ReadOnlyMemory<float> embedding,
|
||||
Dictionary<string, string> metadata = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Insert or Update a Batch of Vectors (Matched by Identifier) ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Count of Stored Vectors</returns>
|
||||
Task<int> UpsertVectorsAsync(
|
||||
IEnumerable<XAiVectorDto> items,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Search Vectors by Cosine Similarity (Top K) ...
|
||||
/// </summary>
|
||||
/// <param name="queryEmbedding"></param>
|
||||
/// <param name="topK"></param>
|
||||
/// <param name="minScore"></param>
|
||||
/// <param name="identifierPrefix">Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<XAiVectorSearchResult>> SearchVectorsAsync(
|
||||
ReadOnlyMemory<float> queryEmbedding,
|
||||
int topK = 5,
|
||||
float minScore = 0f,
|
||||
string identifierPrefix = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Load Vectors whose Identifier Starts with Specified Prefix ...
|
||||
/// </summary>
|
||||
/// <param name="identifierPrefix"></param>
|
||||
/// <param name="includeEmbedding"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<XAiVectorDto>> LoadVectorsAsync(
|
||||
string identifierPrefix,
|
||||
bool includeEmbedding = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
|
||||
/// </summary>
|
||||
/// <param name="identifierPrefix"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>Count of Removed Vectors</returns>
|
||||
Task<int> RemoveVectorsAsync(
|
||||
string identifierPrefix,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user