semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Bug: AddOllamaEmbeddingGenerator

Open blackwire opened this issue 8 months ago • 0 comments

Describe the bug AddOllamaEmbeddingGenerator method is not registering service properly.

Getting the following error. Microsoft.SemanticKernel.KernelException: Service of type 'Microsoft.Extensions.AI.IEmbeddingGenerator2[System.String,Microsoft.Extensions.AI.Embedding1[System.Double]]' not registered.

To Reproduce Works:

let private ollamaEndpoint = Uri("http://127.0.0.1:11434")
let private kernel =
    Kernel.CreateBuilder()
    |> _.AddOllamaTextEmbeddingGeneration("nomic-embed-text", ollamaEndpoint)
    |> _.Build()

let EmbeddingGenerator =
    kernel.GetRequiredService<ITextEmbeddingGenerationService>().AsEmbeddingGenerator()

Errors:

let private ollamaEndpoint = Uri("http://127.0.0.1:11434")
let private kernel =
    Kernel.CreateBuilder()
    |> _.AddOllamaEmbeddingGenerator("nomic-embed-text", ollamaEndpoint)
    |> _.Build()

let EmbeddingGenerator =
    kernel.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>()

Expected behavior I would expect it to be registered properly and work in the same way the "AddOllamaTextEmbeddingGeneration" registration method.

Platform

  • Language: F#
  • Source: Nuget Packages (microsoft.semantickernel.connectors.ollama\1.53.1-alpha, microsoft.extensions.vectordata.abstractions\9.5.0, microsoft.extensions.ai\9.5.0, microsoft.semantickernel\1.53.1)
  • AI model: "nomic-embed-text" using Ollama
  • IDE: JetBrains Rider
  • OS: Windows

blackwire avatar May 22 '25 01:05 blackwire