microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.36k stars 3.14k forks source link

Change the exception __SK_DEFAULT #1264

Closed Alerinos closed 1 year ago

Alerinos commented 1 year ago

If we add memory WithMemoryStorage to the build then an exception pops up Microsoft.SemanticKernel.KernelException: „Service not found: '__SK_DEFAULT' text embedding service not available”

Unfortunately we do not have documentation, so it is worth adding the information that we are missing in the config AddOpenAITextEmbeddingGenerationService. Alternatively, let's add documentation in the code next to this exception.

My code:

var kernel = new KernelBuilder()
            .WithLogger(CreateConsoleLogger())
            .Configure(config => {
                config.AddOpenAITextCompletionService("text-davinci-003", "xxx");
                })
            .WithMemoryStorage(new QdrantMemoryStore("xxx", 6333, 1536, CreateConsoleLogger()))
            .Build();

To bypass the exception it is sufficient to add a config which is missing from the documentation.

config.AddOpenAITextEmbeddingGenerationService("text-embedding-ada-002", "");

https://github.com/microsoft/semantic-kernel/blob/9faa7e935007d8628035c95f009d51ee35b13ab2/dotnet/src/SemanticKernel.Abstractions/KernelConfig.cs#L56

sneha-afk commented 1 year ago

With PR #2013 , AddOpenAITextCompletionService is no longer available, so this issue is not relevant anymore. Now the approach would be:

.WithOpenAITextCompletionService("text-davinci-003", "xxx")
.WithOpenAITextEmbeddingGenerationService("text-embedding-ada-002", "xxx")

Leaving out the text embedding service gives a clearer error message now:

Service not found: Service of type Microsoft.SemanticKernel.AI.Embeddings.ITextEmbeddingGeneration and name <NONE> not registered.
nacharya1 commented 1 year ago

Thanks for informing us about this and glad to hear the issue is now resolved.