You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
An error occurs when creating a Qdrant collection for the first time. However, the collection is created. A subsequent run works fine.
The problem is in await collection.CreateCollectionIfNotExistsAsync();
System.Collections.Generic.KeyNotFoundException
HResult=0x80131577
Message=The given key 'System.String[]' was not present in the dictionary.
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantVectorStoreRecordCollection`1.<CreateCollectionAsync>d__15.MoveNext()
at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantVectorStoreRecordCollection`1.<CreateCollectionIfNotExistsAsync>d__16.MoveNext()
at Program.<<Main>$>d__0.MoveNext() in ...
To Reproduce
#pragma warning disable SKEXP0010
#pragma warning disable SKEXP0001
using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Logging;using Microsoft.Extensions.VectorData;using Microsoft.SemanticKernel;using Microsoft.SemanticKernel.Connectors.Qdrant;using Microsoft.SemanticKernel.Embeddings;using Qdrant.Client;varconfiguration=new ConfigurationBuilder().AddJsonFile("appsettings.json", optional:true).Build();varservices=new ServiceCollection();
services
.AddTransient<IConfiguration>(_ => configuration).AddLogging(configure => configure.AddConfiguration(configuration.GetSection("Logging")).AddConsole());varendpoint="YOUR_ENDPOINT";varapiKey="YOUR_API_KEY";
services.AddAzureOpenAITextEmbeddingGeneration("text-embedding-ada-002", endpoint, apiKey);
services.AddTransient((serviceProvider)=>{returnnew Kernel(serviceProvider);});usingvarscope= services.BuildServiceProvider().CreateScope();varkernel= scope.ServiceProvider.GetRequiredService<Kernel>();varvectorStore=new QdrantVectorStore(new QdrantClient("localhost"));varcollection= vectorStore.GetCollection<ulong,Customer>("skcustomers");await collection.CreateCollectionIfNotExistsAsync();// Here it's the errorasyncTask<ReadOnlyMemory<float>>GenerateEmbeddingAsync(stringtextToVectorize){vartextEmbeddingGenerationService= scope.ServiceProvider.GetRequiredService<ITextEmbeddingGenerationService>();ReadOnlyMemory<float>embedding=await textEmbeddingGenerationService.GenerateEmbeddingAsync(textToVectorize);returnembedding;}constulongcustomerId=1;conststringdescription="It's an amazing company that helps you build new, quality applications with an agile approach.";await collection.UpsertAsync(new Customer
{Id=customerId,Name="BitAttack",Email="[email protected]",Description=description,Tags=["development","software","agile"],DescriptionEmbedding=await GenerateEmbeddingAsync(description),});Customer?retrievedCustomer=await collection.GetAsync(customerId);
Console.WriteLine(retrievedCustomer);publicclassCustomer{[VectorStoreRecordKey]publiculongId{get;set;}[VectorStoreRecordData(IsFilterable =true)]publicstringName{get;set;}[VectorStoreRecordData]publicstringEmail{get;set;}[VectorStoreRecordData(IsFullTextSearchable =true)]publicstringDescription{get;set;}[VectorStoreRecordData(IsFilterable =true)]publicstring[] Tags {get;set;}[VectorStoreRecordVector(Dimensions:1536, DistanceFunction.CosineSimilarity, IndexKind.Hnsw)]publicReadOnlyMemory<float>?DescriptionEmbedding{get;set;}publicoverridestringToString()=>$"Id: {Id}, Name: {Name}, Email: {Email}, Description: {Description}, Tags: {string.Join(", ", Tags)}";}
Expected behavior
Don't fail the first time
Screenshots
If applicable, add screenshots to help explain your problem.
github-actionsbot
changed the title
Bug: Qdrant CreateCollectionIfNotExistsAsync fails for the first time
.Net: Bug: Qdrant CreateCollectionIfNotExistsAsync fails for the first time
Nov 23, 2024
Describe the bug
An error occurs when creating a Qdrant collection for the first time. However, the collection is created. A subsequent run works fine.
The problem is in
await collection.CreateCollectionIfNotExistsAsync();
To Reproduce
Expected behavior
Don't fail the first time
Screenshots
If applicable, add screenshots to help explain your problem.
Platform
Relevant packages used (I think):
Additional context
For now, I can go ahead with this:
The text was updated successfully, but these errors were encountered: