microsoft / kernel-memory

RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
https://microsoft.github.io/kernel-memory
MIT License
1.58k stars 305 forks source link

Exception when trying to create Kernel Memory when using version 1.18.0-rc of Microsoft.SemanticKernel.Connectors.OpenAI #747

Closed shyam-menon closed 2 months ago

shyam-menon commented 2 months ago

Context / Scenario

I am trying to create a Kernel Memory that would be used within the Kernel of an Agent. var memory = new KernelMemoryBuilder() .WithOpenAIDefaults(apiKey) .Build();

As I understand from the Semantic Kernel team, this is happening because Kernel Memory assembly is not updated with the latest changes from SK v1.18.0-rc, which uses Azure/OpenAI v2 SDK

I get the following exception when using the 1.18.0-rc version of Microsoft.SemanticKernel.Connectors.OpenAI but do not get the exception when using the 1.17.1 version.

System.TypeLoadException HResult=0x80131522 Message=Could not load type 'Azure.AI.OpenAI.OpenAIClient' from assembly 'Azure.AI.OpenAI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. Source=Microsoft.KernelMemory.AI.OpenAI StackTrace: at Microsoft.KernelMemory.AI.OpenAI.OpenAITextEmbeddingGenerator..ctor(OpenAIConfig config, ITextTokenizer textTokenizer, ILoggerFactory loggerFactory, HttpClient httpClient) at Microsoft.KernelMemory.KernelMemoryBuilderExtensions.WithOpenAIDefaults(IKernelMemoryBuilder builder, String apiKey, String organization, ITextTokenizer textGenerationTokenizer, ITextTokenizer textEmbeddingTokenizer, ILoggerFactory loggerFactory, Boolean onlyForRetrieval, HttpClient httpClient) at Program.d__6.MoveNext() in C:\Code\Work\SemanticKernel\SemanticKernelSamples\SK_AllinOne\Program.cs:line 74 at Program.

d__5.MoveNext() in C:\Code\Work\SemanticKernel\SemanticKernelSamples\SK_AllinOne\Program.cs:line 59

What happened?

Exception when creating kernel memory using 1.18.0-rc

Importance

I cannot use Kernel Memory

Platform, Language, Versions

.Net 8, C#, 1.18.0-rc

Relevant log output

System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'Azure.AI.OpenAI.OpenAIClient' from assembly 'Azure.AI.OpenAI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'.
Source=Microsoft.KernelMemory.AI.OpenAI
StackTrace:
at Microsoft.KernelMemory.AI.OpenAI.OpenAITextEmbeddingGenerator..ctor(OpenAIConfig config, ITextTokenizer textTokenizer, ILoggerFactory loggerFactory, HttpClient httpClient)
at Microsoft.KernelMemory.KernelMemoryBuilderExtensions.WithOpenAIDefaults(IKernelMemoryBuilder builder, String apiKey, String organization, ITextTokenizer textGenerationTokenizer, ITextTokenizer textEmbeddingTokenizer, ILoggerFactory loggerFactory, Boolean onlyForRetrieval, HttpClient httpClient)
at Program.d__6.MoveNext() in C:\Code\Work\SemanticKernel\SemanticKernelSamples\SK_AllinOne\Program.cs:line 74
at Program.

d__5.MoveNext() in C:\Code\Work\SemanticKernel\SemanticKernelSamples\SK_AllinOne\Program.cs:line 59
dluc commented 2 months ago

@shyam-menon if you're working with unreleased/experimental code, such as RC versions, you might get luckier linking SK sources directly. I don't think this classifies as a bug, does it?