Closed clarity99 closed 7 months ago
I think you're adding the same embedding generator twice when using WithOpenAIDefaults
and WithOpenAITextEmbeddingGeneration
.
try removing WithOpenAIDefaults
, changing this code:
.WithOpenAIDefaults(openAIConfig.APIKey)
.WithOpenAITextEmbeddingGeneration(openAIConfig)
to
.WithOpenAITextGeneration(openAITextConfig)
.WithOpenAITextEmbeddingGeneration(openAIEmbeddingConfig)
Ah, this works, thank you! I wasn't aware that sets both generation and embeddings.
Context / Scenario
I just want to add document to the memory store and I get this error. Code:
KM is setup as follows:
What happened?
I got an exception System.ArgumentException: An item with the same key has already been added. Key: perls.pdf.partition.0.txt.AI.OpenAI.OpenAITextEmbeddingGenerator.TODO.text_embedding at System.Collections.Generic.Dictionary
2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary
2.Add(TKey key, TValue value) at Microsoft.KernelMemory.Handlers.GenerateEmbeddingsHandler.InvokeAsync(DataPipeline pipeline, CancellationToken cancellationToken)Importance
I cannot use Kernel Memory
Platform, Language, Versions
.net 8, macos sonoma 14.4.1, KM 0.36.240415.2 c#
Relevant log output