-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codemsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Description
Throughout all providers, we have code such as the following, which successively tries all the vector types supported by the provider:
if (vectorProperty.TryGenerateEmbedding<TRecord, Embedding<float>>(record, cancellationToken, out var floatTask))
{
generatedEmbeddings ??= new Dictionary<VectorPropertyModel, IReadOnlyList<Embedding>>(vectorPropertyCount);
generatedEmbeddings[vectorProperty] = [await floatTask.ConfigureAwait(false)];
}
#if NET8_0_OR_GREATER
else if (vectorProperty.TryGenerateEmbedding<TRecord, Embedding<Half>>(record, cancellationToken, out var halfTask))
{
generatedEmbeddings ??= new Dictionary<VectorPropertyModel, IReadOnlyList<Embedding>>(vectorPropertyCount);
generatedEmbeddings[vectorProperty] = [await halfTask.ConfigureAwait(false)];
}
#endif
else
{
throw new InvalidOperationException(
$"The embedding generator configured on property '{vectorProperty.ModelName}' cannot produce an embedding of type '{typeof(Embedding<float>).Name}' for the given input type.");
}
This should be factored out to generic logic, ideally in the model, so that providers can be made simpler. This may involve a merging of the current CollectionModel and CollectionModelBuilder types.
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codemsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Type
Projects
Status
Sprint: Planned