Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException: ITextEmbeddingGenerationService not registered #17

Open
labidiaymen opened this issue Aug 29, 2024 · 0 comments

Comments

@labidiaymen
Copy link

Hello

I’m encountering an issue while using `Codeblaze.SemanticKernel.Connectors.Ollama version 1.3.1. My code is throwing a System.InvalidOperationException, indicating that the ITextEmbeddingGenerationService has not been registered.

Here is a snippet of the code that leads to the error:

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Embeddings;
using Microsoft.SemanticKernel.Memory;
using Microsoft.SemanticKernel.Plugins.Memory;
using TransactionChecker;
using Codeblaze.SemanticKernel.Connectors.Ollama;

var config = new ConfigurationBuilder()
    .AddUserSecrets<Config>()
    .Build();

var builder = Kernel.CreateBuilder();
builder.Services.AddTransient<HttpClient>();

builder.Services.AddSingleton<IConfiguration>(config);

#pragma warning disable SKEXP0070
builder.AddOllamaTextEmbeddingGeneration(
    modelId: "mistral",
    baseUrl: "http://localhost:11434"
);

builder.AddOllamaChatCompletion(
    modelId: "mistral",
    baseUrl: "http://localhost:11434"
);

var kernel = builder.Build();

var embeddingGenerator = kernel.Services.GetRequiredService<ITextEmbeddingGenerationService>();

Error:
System.InvalidOperationException: 'No service for type 'Microsoft.SemanticKernel.Embeddings.ITextEmbeddingGenerationService' has been registered.'

It appears that the ITextEmbeddingGenerationService is not being properly registered within the DI container.

<ItemGroup>
   <PackageReference Include="Codeblaze.SemanticKernel.Connectors.Ollama" Version="1.3.1" />
   <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.41.0" />
   <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
   <PackageReference Include="Microsoft.SemanticKernel" Version="1.17.2" />
   <PackageReference Include="Microsoft.SemanticKernel.Connectors.MistralAI" Version="1.18.0-alpha" />
   <PackageReference Include="Microsoft.SemanticKernel.Planners.Handlebars" Version="1.15.1-preview" />
   <PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.18.0-alpha" />
</ItemGroup>

Here’s the list of package references included in my project:

Is there something I’m missing in the registration process, or is there a known issue with this version? Any guidance would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant