Skip to content

.Net: New Feature: Support HttpClient injection for Ollama connectors (embedding and chat) #12293

@ramonduraes

Description

@ramonduraes

Hello team,

We're currently using Microsoft.SemanticKernel.Connectors.Ollama (v1.54.0-alpha) to integrate local LLMs via Ollama. While the experience is great overall, we noticed that the current extension methods:

  • AddOllamaEmbeddingGenerator(...)
  • AddOllamaChatCompletion(...)

do not allow passing a custom HttpClient, which makes it impossible to configure critical options such as Timeout, custom headers, retry policies, or advanced diagnostics.

This is a limitation especially for local LLMs like llama3.2:3b or mistral, which may take longer than 100 seconds on first generation, leading to TaskCanceledException.

We kindly suggest either:

  1. Adding overloads that support injecting a preconfigured HttpClient
  2. Or allowing DI via options/configuration pattern

This change would align with .NET best practices and enable full control over networking behavior when using Ollama.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codetriage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions