-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencebugSomething isn't workingSomething isn't workingmsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Description
Describe the bug
Exception in InMemoryVectorStore when using SearchAsync
An exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll but was not handled in user code: ''SearchAsync' requires an embedding generator to be configured. To pass an embedding directly, use 'SearchEmbeddingAsync', otherwise configure an embedding generator with your vector store connector.'
at Microsoft.SemanticKernel.Connectors.InMemory.InMemoryVectorStoreRecordCollection`2.<SearchAsync>d__23`1.MoveNext()
at Microsoft.SemanticKernel.Connectors.InMemory.InMemoryVectorStoreRecordCollection`2.<SearchAsync>d__23`1.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
To Reproduce
Using the sample as basis from https://devblogs.microsoft.com/dotnet/introducing-microsoft-extensions-vector-data/ (slightly updated to fix obsoletions)
Source is attached.
Steps to reproduce the behavior:
- Using latest packages
<PackageReference Include="Microsoft.Extensions.AI.Ollama" Version="9.4.3-preview.1.25230.7" />
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25229.1" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.48.0-preview" />- Set up the collection using a default EmbeddingGenerator
var generator = new OllamaEmbeddingGenerator(new Uri("http://localhost:11434/"), "all-minilm");
var vectorStore = new InMemoryVectorStore(new InMemoryVectorStoreOptions { EmbeddingGenerator = generator });
var movies = vectorStore.GetCollection<int, Movie>("movies");
await movies.CreateCollectionIfNotExistsAsync();- Search throws; also Upsert does not generate embeddings
Expected behavior
Store should us the EmbeddingGenerator passed to the constructor. Looking at the source it seems it's checking if the Vector* attributes on the POCO properties have the generator specified, but does not fallback to default.
Platform
- Language:C# .NET 9
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencebugSomething isn't workingSomething isn't workingmsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Type
Projects
Status
Sprint: Done