Skip to content

Update Ollama Microsoft.Extensions.AI integration documentation to use current recommended patterns #4145

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

Merged
merged 6 commits into from
Jul 24, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 23, 2025

The Microsoft.Extensions.AI integration section in the Ollama documentation was using deprecated methods that are no longer recommended in .NET Aspire 9.0. The image in the issue shows these deprecated methods:

builder.AddOllamaSharpChatClient("llama32");
builder.AddOllamaApiClient("llama32").AddChatClient();

This PR updates the documentation to use the current recommended patterns that are consistent with other .NET Aspire AI integrations (Azure OpenAI, Azure AI Inference).

Changes Made

  • Removed deprecated methods: Eliminated AddOllamaSharpChatClient examples
  • Updated to current pattern: Now uses AddOllamaClientApi("llama").AddChatClient() following the same pattern as Azure OpenAI integration
  • Added embedding support: Included AddEmbeddingGenerator() examples for complete Microsoft.Extensions.AI coverage
  • Enhanced keyed services: Added comprehensive section for registering multiple AI client instances with different connection names
  • Improved examples: Updated dependency injection examples to show both chat and embedding clients

New Pattern

For chat clients:

builder.AddOllamaClientApi("llama")
       .AddChatClient();

For embedding generators:

builder.AddOllamaClientApi("llama")
       .AddEmbeddingGenerator();

For keyed services:

builder.AddOllamaClientApi("chat")
       .AddKeyedChatClient("chat");
builder.AddOllamaClientApi("embeddings")
       .AddKeyedEmbeddingGenerator("embeddings");

The updated documentation now follows the established pattern used across all .NET Aspire AI integrations and reflects the changes introduced in .NET Aspire Community Toolkit 9.0 with OllamaSharp 4.

Fixes #4131.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/community-toolkit/ollama.md docs/community-toolkit/ollama

…mmended patterns

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Outdated Documentation for Integration with Microsoft.Extensions.AI Update Ollama Microsoft.Extensions.AI integration documentation to use current recommended patterns Jul 23, 2025
@Copilot Copilot AI requested a review from IEvangelist July 23, 2025 12:54
Copilot finished work on behalf of IEvangelist July 23, 2025 12:54
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copilot finished work on behalf of IEvangelist July 23, 2025 13:47
@Copilot Copilot AI requested a review from IEvangelist July 23, 2025 13:47
@IEvangelist IEvangelist marked this pull request as ready for review July 23, 2025 13:59
@IEvangelist IEvangelist enabled auto-merge (squash) July 23, 2025 13:59
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
auto-merge was automatically disabled July 23, 2025 15:42

Head branch was pushed to by a user without write access

Copilot finished work on behalf of gewarren July 23, 2025 15:43
@Copilot Copilot AI requested a review from gewarren July 23, 2025 15:43
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
@Copilot Copilot AI requested a review from gewarren July 23, 2025 15:50
Copilot finished work on behalf of gewarren July 23, 2025 15:50
@IEvangelist
Copy link
Member

Hey @copilot please revert the changes from 48b1cd6 as these xref's don't actually exist.

…tation

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 24, 2025

Hey @copilot please revert the changes from 48b1cd6 as these xref's don't actually exist.

Reverted in b893496. Removed the xref links for community toolkit methods and restored the original backtick formatting since these APIs are not published to API documentation.

Copilot finished work on behalf of IEvangelist July 24, 2025 16:16
@IEvangelist IEvangelist merged commit 65b0657 into main Jul 24, 2025
9 checks passed
@IEvangelist IEvangelist deleted the copilot/fix-4131 branch July 24, 2025 18:47
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

Successfully merging this pull request may close these issues.

Outdated Documentation for Integration with Microsoft.Extensions.AI
3 participants