From d68638462fead581bded09b66b0193eb91f69f86 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Thu, 29 May 2025 10:20:09 -0700
Subject: [PATCH 1/6] add sample ichatclient and iembeddinggenerator impls

---
 docs/ai/advanced/sample-implementations.md    | 40 +++++++++++++++++++
 .../Implementations.csproj                    | 13 ++++++
 .../SampleChatClient.cs                       |  6 ++-
 .../SampleEmbeddingGenerator.cs               |  6 +--
 .../conceptual/chain-of-thought-prompting.md  | 16 ++++----
 docs/ai/microsoft-extensions-ai.md            | 23 +++--------
 .../ConsoleAI.AddMessages.csproj              |  4 ++
 .../ConsoleAI.AddMessages/Program.cs          |  5 ++-
 .../ConsoleAI.ConsumeClientMiddleware.csproj  |  1 +
 .../Program.cs                                |  7 +++-
 ...soleAI.ConsumeRateLimitingEmbedding.csproj |  4 ++
 .../Program.cs                                |  3 +-
 .../ConsoleAI.CreateEmbeddings.csproj         |  4 ++
 .../ConsoleAI.CreateEmbeddings/Program.cs     |  4 +-
 .../ConsoleAI.CustomEmbeddingsMiddle.csproj   |  1 +
 .../Program.cs                                |  3 +-
 .../ConsoleAI.GetResponseAsyncArgs.csproj     |  4 ++
 .../ConsoleAI.GetResponseAsyncArgs/Program.cs |  5 ++-
 ...ConsoleAI.GetStreamingResponseAsync.csproj |  4 ++
 .../Program.cs                                |  5 ++-
 .../ConsoleAI.UseTelemetry.csproj             |  1 +
 .../ConsoleAI.UseTelemetry/Program.cs         |  7 ++--
 .../ConsoleAI/ConsoleAI.csproj                |  1 +
 .../ConsoleAI/Program.cs                      |  5 ++-
 docs/ai/toc.yml                               |  4 ++
 25 files changed, 129 insertions(+), 47 deletions(-)
 create mode 100644 docs/ai/advanced/sample-implementations.md
 create mode 100644 docs/ai/advanced/snippets/sample-implementations/Implementations.csproj
 rename docs/ai/{snippets/microsoft-extensions-ai/AI.Shared => advanced/snippets/sample-implementations}/SampleChatClient.cs (93%)
 rename docs/ai/{snippets/microsoft-extensions-ai/AI.Shared => advanced/snippets/sample-implementations}/SampleEmbeddingGenerator.cs (84%)

diff --git a/docs/ai/advanced/sample-implementations.md b/docs/ai/advanced/sample-implementations.md
new file mode 100644
index 0000000000000..2da98007a6405
--- /dev/null
+++ b/docs/ai/advanced/sample-implementations.md
@@ -0,0 +1,40 @@
+---
+title: "Sample implementations of IChatClient and IEmbeddingGenerator"
+description:
+ms.topic: article
+ms.date: 05/28/2025
+---
+
+# Sample implementations of IChatClient and IEmbeddingGenerator
+
+.NET libraries that provide clients for language models and services can provide an implementations of the <xref:Microsoft.Extensions.AI.IChatClient> and <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interfaces. Any consumers of the interfaces are then able to interoperate seamlessly with these models and services via the abstractions.
+
+## The `IChatClient` interface
+
+The <xref:Microsoft.Extensions.AI.IChatClient> interface defines a client abstraction responsible for interacting with AI services that provide chat capabilities. It includes methods for sending and receiving messages with multi-modal content (such as text, images, and audio), either as a complete set or streamed incrementally. Additionally, it allows for retrieving strongly typed services provided by the client or its underlying services.
+
+.NET libraries that provide clients for language models and services can provide an implementation of the `IChatClient` interface. Any consumers of the interface are then able to interoperate seamlessly with these models and services via the abstractions.
+
+The following sample implements `IChatClient` to show the general structure.
+
+:::code language="csharp" source="./snippets/sample-implementations/SampleChatClient.cs":::
+
+For more realistic, concrete implementations of `IChatClient`, see:
+
+- [AzureAIInferenceChatClient.cs](https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI.AzureAIInference/AzureAIInferenceChatClient.cs)
+- [OpenAIChatClient.cs](https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs)
+- [Microsoft.Extensions.AI chat clients](https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.AI/ChatCompletion)
+
+## The `IEmbeddingGenerator<TInput,TEmbedding>` interface
+
+The <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interface represents a generic generator of embeddings. Here, `TInput` is the type of input values being embedded, and `TEmbedding` is the type of generated embedding, which inherits from the <xref:Microsoft.Extensions.AI.Embedding> class.
+
+The `Embedding` class serves as a base class for embeddings generated by an `IEmbeddingGenerator<TInput,TEmbedding>`. It's designed to store and manage the metadata and data associated with embeddings. Derived types, like `Embedding<T>`, provide the concrete embedding vector data. For example, an `Embedding<float>` exposes a `ReadOnlyMemory<float> Vector { get; }` property for access to its embedding data.
+
+The `IEmbeddingGenerator<TInput,TEmbedding>` interface defines a method to asynchronously generate embeddings for a collection of input values, with optional configuration and cancellation support. It also provides metadata describing the generator and allows for the retrieval of strongly typed services that can be provided by the generator or its underlying services.
+
+The following code shows how the `SampleEmbeddingGenerator` class implements the `IEmbeddingGenerator<TInput,TEmbedding>` interface. It has a primary constructor that accepts an endpoint and model ID, which are used to identify the generator. It also implements the <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2.GenerateAsync(System.Collections.Generic.IEnumerable{`0},Microsoft.Extensions.AI.EmbeddingGenerationOptions,System.Threading.CancellationToken)> method to generate embeddings for a collection of input values.
+
+:::code language="csharp" source="./snippets/sample-implementations/SampleEmbeddingGenerator.cs":::
+
+This sample implementation just generates random embedding vectors. For a more realistic, concrete implementation, see [OpenTelemetryEmbeddingGenerator.cs](https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI/Embeddings/OpenTelemetryEmbeddingGenerator.cs).
diff --git a/docs/ai/advanced/snippets/sample-implementations/Implementations.csproj b/docs/ai/advanced/snippets/sample-implementations/Implementations.csproj
new file mode 100644
index 0000000000000..efb828e6cb8ee
--- /dev/null
+++ b/docs/ai/advanced/snippets/sample-implementations/Implementations.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net9.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.5.0" />
+  </ItemGroup>
+
+</Project>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleChatClient.cs b/docs/ai/advanced/snippets/sample-implementations/SampleChatClient.cs
similarity index 93%
rename from docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleChatClient.cs
rename to docs/ai/advanced/snippets/sample-implementations/SampleChatClient.cs
index 616abbb121370..0b8039cca7906 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleChatClient.cs
+++ b/docs/ai/advanced/snippets/sample-implementations/SampleChatClient.cs
@@ -1,9 +1,11 @@
 using System.Runtime.CompilerServices;
 using Microsoft.Extensions.AI;
 
-public sealed class SampleChatClient(Uri endpoint, string modelId) : IChatClient
+public sealed class SampleChatClient(Uri endpoint, string modelId)
+    : IChatClient
 {
-    public ChatClientMetadata Metadata { get; } = new(nameof(SampleChatClient), endpoint, modelId);
+    public ChatClientMetadata Metadata { get; } =
+        new(nameof(SampleChatClient), endpoint, modelId);
 
     public async Task<ChatResponse> GetResponseAsync(
         IEnumerable<ChatMessage> chatMessages,
diff --git a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleEmbeddingGenerator.cs b/docs/ai/advanced/snippets/sample-implementations/SampleEmbeddingGenerator.cs
similarity index 84%
rename from docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleEmbeddingGenerator.cs
rename to docs/ai/advanced/snippets/sample-implementations/SampleEmbeddingGenerator.cs
index ddf1e6b53aa28..2b08d28b25a22 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/AI.Shared/SampleEmbeddingGenerator.cs
+++ b/docs/ai/advanced/snippets/sample-implementations/SampleEmbeddingGenerator.cs
@@ -16,10 +16,10 @@ public async Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(
         await Task.Delay(100, cancellationToken);
 
         // Create random embeddings.
-        return new GeneratedEmbeddings<Embedding<float>>(
-            from value in values
+        return [.. from value in values
             select new Embedding<float>(
-                Enumerable.Range(0, 384).Select(_ => Random.Shared.NextSingle()).ToArray()));
+                Enumerable.Range(0, 384)
+                .Select(_ => Random.Shared.NextSingle()).ToArray())];
     }
 
     public object? GetService(Type serviceType, object? serviceKey) =>
diff --git a/docs/ai/conceptual/chain-of-thought-prompting.md b/docs/ai/conceptual/chain-of-thought-prompting.md
index 20d3d234b1984..0c9c46fb93e5a 100644
--- a/docs/ai/conceptual/chain-of-thought-prompting.md
+++ b/docs/ai/conceptual/chain-of-thought-prompting.md
@@ -1,8 +1,8 @@
 ---
-title: "Chain of Thought Prompting - .NET"
+title: "Chain of thought prompting"
 description: "Learn how chain of thought prompting can simplify prompt engineering."
 author: catbutler
-ms.topic: concept-article #Don't change.
+ms.topic: concept-article
 ms.date: 11/24/2024
 
 #customer intent: As a .NET developer, I want to understand what chain-of-thought prompting is and how it can help me save time and get better completions out of prompt engineering.
@@ -23,7 +23,7 @@ To use an instruction for chain of thought prompting, include a directive that t
 
 ```csharp
 prompt= """Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles.
-Break the task into steps, and output the result of each step as you perform it."""; 
+Break the task into steps, and output the result of each step as you perform it.""";
 ```
 
 ## Use chain of thought prompting in examples
@@ -35,16 +35,16 @@ prompt= """
         Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles.
 
         Differences between EVs and petroleum-fueled vehicles:
-        - 
+        -
+
+        Differences ordered according to overall impact, highest-impact first:
+        1.
 
-        Differences ordered according to overall impact, highest-impact first: 
-        1. 
-        
         Summary of vehicle type differences as pros and cons:
         Pros of EVs
         1.
         Pros of petroleum-fueled vehicles
-        1. 
+        1.
         """;
 ```
 
diff --git a/docs/ai/microsoft-extensions-ai.md b/docs/ai/microsoft-extensions-ai.md
index d2e3521ea75fe..5e204f1963888 100644
--- a/docs/ai/microsoft-extensions-ai.md
+++ b/docs/ai/microsoft-extensions-ai.md
@@ -43,7 +43,6 @@ The following subsections show specific [IChatClient](#the-ichatclient-interface
 
 The following sections show specific [IEmbeddingGenerator](#the-iembeddinggenerator-interface) usage examples:
 
-- [Sample implementation](#sample-implementation)
 - [Create embeddings](#create-embeddings)
 - [Pipelines of functionality](#pipelines-of-functionality)
 
@@ -51,7 +50,7 @@ The following sections show specific [IEmbeddingGenerator](#the-iembeddinggenera
 
 The <xref:Microsoft.Extensions.AI.IChatClient> interface defines a client abstraction responsible for interacting with AI services that provide chat capabilities. It includes methods for sending and receiving messages with multi-modal content (such as text, images, and audio), either as a complete set or streamed incrementally. Additionally, it allows for retrieving strongly typed services provided by the client or its underlying services.
 
-.NET libraries that provide clients for language models and services can provide an implementation of the `IChatClient` interface. Any consumers of the interface are then able to interoperate seamlessly with these models and services via the abstractions.
+.NET libraries that provide clients for language models and services can provide an implementation of the `IChatClient` interface. Any consumers of the interface are then able to interoperate seamlessly with these models and services via the abstractions. You can see a simple implementation at [Sample implementations of IChatClient and IEmbeddingGenerator](advanced/sample-implementations.md).
 
 #### Request a chat response
 
@@ -195,25 +194,13 @@ If you don't know ahead of time whether the service is stateless or stateful, yo
 
 ### The `IEmbeddingGenerator` interface
 
-The <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interface represents a generic generator of embeddings. Here, `TInput` is the type of input values being embedded, and `TEmbedding` is the type of generated embedding, which inherits from the <xref:Microsoft.Extensions.AI.Embedding> class.
+The <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interface represents a generic generator of embeddings. For the generic type parameters, `TInput` is the type of input values being embedded, and `TEmbedding` is the type of generated embedding, which inherits from the <xref:Microsoft.Extensions.AI.Embedding> class.
 
-The `Embedding` class serves as a base class for embeddings generated by an `IEmbeddingGenerator`. It's designed to store and manage the metadata and data associated with embeddings. Derived types, like `Embedding<T>`, provide the concrete embedding vector data. For example, an `Embedding<float>` exposes a `ReadOnlyMemory<float> Vector { get; }` property for access to its embedding data.
+The `Embedding` class serves as a base class for embeddings generated by an `IEmbeddingGenerator`. It's designed to store and manage the metadata and data associated with embeddings. Derived types, like <xref:Microsoft.Extensions.AI.Embedding`1>, provide the concrete embedding vector data. For example, an `Embedding<float>` exposes a `ReadOnlyMemory<float> Vector { get; }` property for access to its embedding data.
 
 The `IEmbeddingGenerator` interface defines a method to asynchronously generate embeddings for a collection of input values, with optional configuration and cancellation support. It also provides metadata describing the generator and allows for the retrieval of strongly typed services that can be provided by the generator or its underlying services.
 
-#### Sample implementation
-
-The following sample implementation of `IEmbeddingGenerator` shows the general structure.
-
-:::code language="csharp" source="snippets/microsoft-extensions-ai/AI.Shared/SampleEmbeddingGenerator.cs":::
-
-The preceding code:
-
-- Defines a class named `SampleEmbeddingGenerator` that implements the `IEmbeddingGenerator<string, Embedding<float>>` interface.
-- Has a primary constructor that accepts an endpoint and model ID, which are used to identify the generator.
-- Implements the `GenerateAsync` method to generate embeddings for a collection of input values.
-
-The sample implementation just generates random embedding vectors. You can find a concrete implementation in the [📦 Microsoft.Extensions.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) package.
+Most users don't need to implement the `IEmbeddingGenerator` interface. However, if you're a library author, you can see a simple implementation at [Sample implementations of IChatClient and IEmbeddingGenerator](advanced/sample-implementations.md).
 
 #### Create embeddings
 
@@ -247,7 +234,7 @@ In this way, the `RateLimitingEmbeddingGenerator` can be composed with other `IE
 
 You can start building with `Microsoft.Extensions.AI` in the following ways:
 
-- **Library developers**: If you own libraries that provide clients for AI services, consider implementing the interfaces in your libraries. This allows users to easily integrate your NuGet package via the abstractions.
+- **Library developers**: If you own libraries that provide clients for AI services, consider implementing the interfaces in your libraries. This allows users to easily integrate your NuGet package via the abstractions. For example implementations, see [Sample implementations of IChatClient and IEmbeddingGenerator](advanced/sample-implementations.md).
 - **Service consumers**: If you're developing libraries that consume AI services, use the abstractions instead of hardcoding to a specific AI service. This approach gives your consumers the flexibility to choose their preferred provider.
 - **Application developers**: Use the abstractions to simplify integration into your apps. This enables portability across models and services, facilitates testing and mocking, leverages middleware provided by the ecosystem, and maintains a consistent API throughout your app, even if you use different services in different parts of your application.
 - **Ecosystem contributors**: If you're interested in contributing to the ecosystem, consider writing custom middleware components.
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/ConsoleAI.AddMessages.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/ConsoleAI.AddMessages.csproj
index 821fdd5c951db..e64080331bc30 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/ConsoleAI.AddMessages.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/ConsoleAI.AddMessages.csproj
@@ -7,6 +7,10 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
+  </ItemGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/Program.cs
index af06bf9c80829..b2e0466ce0d74 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.AddMessages/Program.cs
@@ -1,7 +1,8 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 
-IChatClient client = new SampleChatClient(
-    new Uri("http://coolsite.ai"), "target-ai-model");
+IChatClient client = new OllamaApiClient(
+    new Uri("http://localhost:11434/"), "phi3:mini");
 
 // <Snippet1>
 List<ChatMessage> history = [];
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj
index bec56340237d7..697bf0cf24c7a 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/ConsoleAI.ConsumeClientMiddleware.csproj
@@ -9,6 +9,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.3.25171.5" />
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
 
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/Program.cs
index d59952ee6f485..cf72dad6c4d06 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeClientMiddleware/Program.cs
@@ -3,12 +3,17 @@
 using Microsoft.Extensions.AI;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
+using OllamaSharp;
 
 // <SnippetUse>
 HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
 
+IChatClient client = new OllamaApiClient(
+    new Uri("http://localhost:11434/"),
+    "phi3:mini");
+
 builder.Services.AddChatClient(services =>
-    new SampleChatClient(new Uri("http://localhost"), "test")
+        client
         .AsBuilder()
         .UseDistributedCache()
         .UseRateLimiting()
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj
index b615dd1b868c2..6e0c682243e90 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/ConsoleAI.ConsumeRateLimitingEmbedding.csproj
@@ -7,6 +7,10 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
+  </ItemGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/Program.cs
index b6bb41eb7e5af..4ce9b0ca7d089 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.ConsumeRateLimitingEmbedding/Program.cs
@@ -1,9 +1,10 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 using System.Threading.RateLimiting;
 
 IEmbeddingGenerator<string, Embedding<float>> generator =
     new RateLimitingEmbeddingGenerator(
-        new SampleEmbeddingGenerator(new Uri("http://coolsite.ai"), "target-ai-model"),
+        new OllamaApiClient(new Uri("http://localhost:11434/"), "phi3:mini"),
         new ConcurrencyLimiter(new()
         {
             PermitLimit = 1,
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj
index b615dd1b868c2..6e0c682243e90 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/ConsoleAI.CreateEmbeddings.csproj
@@ -7,6 +7,10 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
+  </ItemGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/Program.cs
index dfe3a9e5da91d..de2641558fe00 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CreateEmbeddings/Program.cs
@@ -1,9 +1,9 @@
 // <Snippet1>
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 
 IEmbeddingGenerator<string, Embedding<float>> generator =
-    new SampleEmbeddingGenerator(
-        new Uri("http://coolsite.ai"), "target-ai-model");
+    new OllamaApiClient(new Uri("http://localhost:11434/"), "phi3:mini");
 
 foreach (Embedding<float> embedding in
     await generator.GenerateAsync(["What is AI?", "What is .NET?"]))
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj
index 5cd740ab9bb58..f83ec782c16dc 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/ConsoleAI.CustomEmbeddingsMiddle.csproj
@@ -9,6 +9,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0-preview.4.25258.110" />
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
     <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/Program.cs
index f35794faf6dff..97314bfb4e72d 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.CustomEmbeddingsMiddle/Program.cs
@@ -2,6 +2,7 @@
 using Microsoft.Extensions.Caching.Distributed;
 using Microsoft.Extensions.Caching.Memory;
 using Microsoft.Extensions.Options;
+using OllamaSharp;
 using OpenTelemetry.Trace;
 
 // Configure OpenTelemetry exporter
@@ -14,7 +15,7 @@
 // Explore changing the order of the intermediate "Use" calls to see
 // what impact that has on what gets cached and traced.
 IEmbeddingGenerator<string, Embedding<float>> generator = new EmbeddingGeneratorBuilder<string, Embedding<float>>(
-        new SampleEmbeddingGenerator(new Uri("http://coolsite.ai"), "target-ai-model"))
+        new OllamaApiClient(new Uri("http://localhost:11434/"), "phi3:mini"))
     .UseDistributedCache(
         new MemoryDistributedCache(
             Options.Create(new MemoryDistributedCacheOptions())))
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj
index b615dd1b868c2..6e0c682243e90 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/ConsoleAI.GetResponseAsyncArgs.csproj
@@ -7,6 +7,10 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
+  </ItemGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/Program.cs
index 92bb0e9f6891b..0dfb9ddbb5364 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetResponseAsyncArgs/Program.cs
@@ -1,7 +1,8 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 
-IChatClient client = new SampleChatClient(
-    new Uri("http://coolsite.ai"), "target-ai-model");
+IChatClient client = new OllamaApiClient(
+    new Uri("http://localhost:11434/"), "phi3:mini");
 
 // <Snippet1>
 Console.WriteLine(await client.GetResponseAsync(
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj
index b615dd1b868c2..6e0c682243e90 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/ConsoleAI.GetStreamingResponseAsync.csproj
@@ -7,6 +7,10 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
 
+  <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
+  </ItemGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\AI.Shared\AI.Shared.csproj" />
   </ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/Program.cs
index 37f80109796ce..a3e5531344276 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.GetStreamingResponseAsync/Program.cs
@@ -1,7 +1,8 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 
-IChatClient client = new SampleChatClient(
-    new Uri("http://coolsite.ai"), "target-ai-model");
+IChatClient client = new OllamaApiClient(
+    new Uri("http://localhost:11434/"), "phi3:mini");
 
 // <Snippet1>
 await foreach (ChatResponseUpdate update in client.GetStreamingResponseAsync("What is AI?"))
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/ConsoleAI.UseTelemetry.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/ConsoleAI.UseTelemetry.csproj
index 4b83cfa2dfb35..1b4af64b74041 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/ConsoleAI.UseTelemetry.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/ConsoleAI.UseTelemetry.csproj
@@ -8,6 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
     <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
   </ItemGroup>
 
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/Program.cs
index db1c7a2502712..4a0b7fc620d48 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI.UseTelemetry/Program.cs
@@ -1,4 +1,5 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 using OpenTelemetry.Trace;
 
 // Configure OpenTelemetry exporter.
@@ -8,10 +9,10 @@
     .AddConsoleExporter()
     .Build();
 
-var sampleChatClient = new SampleChatClient(
-    new Uri("http://coolsite.ai"), "target-ai-model");
+IChatClient ollamaClient = new OllamaApiClient(
+    new Uri("http://localhost:11434/"), "phi3:mini");
 
-IChatClient client = new ChatClientBuilder(sampleChatClient)
+IChatClient client = new ChatClientBuilder(ollamaClient)
     .UseOpenTelemetry(
         sourceName: sourceName,
         configure: c => c.EnableSensitiveData = true)
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
index a001a0f99a5b2..a5e809fa597f1 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
@@ -9,6 +9,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
+    <PackageReference Include="OllamaSharp" Version="5.1.19" />
   </ItemGroup>
 
   <ItemGroup>
diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/Program.cs b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/Program.cs
index f92735dee5e72..4543467a9a112 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/Program.cs
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/Program.cs
@@ -1,6 +1,7 @@
 using Microsoft.Extensions.AI;
+using OllamaSharp;
 
-IChatClient client = new SampleChatClient(
-    new Uri("http://coolsite.ai"), "target-ai-model");
+IChatClient client = new OllamaApiClient(
+    new Uri("http://localhost:11434/"), "phi3:mini");
 
 Console.WriteLine(await client.GetResponseAsync("What is AI?"));
diff --git a/docs/ai/toc.yml b/docs/ai/toc.yml
index b2094a9ffad56..5b2b95be506f7 100644
--- a/docs/ai/toc.yml
+++ b/docs/ai/toc.yml
@@ -91,6 +91,10 @@ items:
       href: tutorials/evaluate-with-reporting.md
     - name: "Evaluate response safety with caching and reporting"
       href: tutorials/evaluate-safety.md
+- name: Advanced
+  items:
+  - name: Sample interface implementations
+    href: advanced/sample-implementations.md
 - name: Resources
   items:
   - name: API reference

From 927c58a858a3a9502fdb81a26b30208c02e86c20 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Thu, 29 May 2025 10:23:51 -0700
Subject: [PATCH 2/6] reset file

---
 docs/ai/conceptual/chain-of-thought-prompting.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/docs/ai/conceptual/chain-of-thought-prompting.md b/docs/ai/conceptual/chain-of-thought-prompting.md
index 0c9c46fb93e5a..20d3d234b1984 100644
--- a/docs/ai/conceptual/chain-of-thought-prompting.md
+++ b/docs/ai/conceptual/chain-of-thought-prompting.md
@@ -1,8 +1,8 @@
 ---
-title: "Chain of thought prompting"
+title: "Chain of Thought Prompting - .NET"
 description: "Learn how chain of thought prompting can simplify prompt engineering."
 author: catbutler
-ms.topic: concept-article
+ms.topic: concept-article #Don't change.
 ms.date: 11/24/2024
 
 #customer intent: As a .NET developer, I want to understand what chain-of-thought prompting is and how it can help me save time and get better completions out of prompt engineering.
@@ -23,7 +23,7 @@ To use an instruction for chain of thought prompting, include a directive that t
 
 ```csharp
 prompt= """Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles.
-Break the task into steps, and output the result of each step as you perform it.""";
+Break the task into steps, and output the result of each step as you perform it."""; 
 ```
 
 ## Use chain of thought prompting in examples
@@ -35,16 +35,16 @@ prompt= """
         Instructions: Compare the pros and cons of EVs and petroleum-fueled vehicles.
 
         Differences between EVs and petroleum-fueled vehicles:
-        -
-
-        Differences ordered according to overall impact, highest-impact first:
-        1.
+        - 
 
+        Differences ordered according to overall impact, highest-impact first: 
+        1. 
+        
         Summary of vehicle type differences as pros and cons:
         Pros of EVs
         1.
         Pros of petroleum-fueled vehicles
-        1.
+        1. 
         """;
 ```
 

From 85e1a910df7e9e67fefaf1dc3c60c498734069b3 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Thu, 29 May 2025 10:42:54 -0700
Subject: [PATCH 3/6] add description

---
 docs/ai/advanced/sample-implementations.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/ai/advanced/sample-implementations.md b/docs/ai/advanced/sample-implementations.md
index 2da98007a6405..fb560f7e601dd 100644
--- a/docs/ai/advanced/sample-implementations.md
+++ b/docs/ai/advanced/sample-implementations.md
@@ -1,6 +1,6 @@
 ---
 title: "Sample implementations of IChatClient and IEmbeddingGenerator"
-description:
+description: Learn more about the IChatClient and IEmbeddingGenerator interfaces, see simple implementations, and find links to concrete implementations.
 ms.topic: article
 ms.date: 05/28/2025
 ---

From 2c03fe7e3e1882af2843763f315e07d8d2492dd6 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Thu, 29 May 2025 10:46:52 -0700
Subject: [PATCH 4/6] remove duplicated text

---
 docs/ai/advanced/sample-implementations.md | 2 --
 1 file changed, 2 deletions(-)

diff --git a/docs/ai/advanced/sample-implementations.md b/docs/ai/advanced/sample-implementations.md
index fb560f7e601dd..cd0bf2444da25 100644
--- a/docs/ai/advanced/sample-implementations.md
+++ b/docs/ai/advanced/sample-implementations.md
@@ -13,8 +13,6 @@ ms.date: 05/28/2025
 
 The <xref:Microsoft.Extensions.AI.IChatClient> interface defines a client abstraction responsible for interacting with AI services that provide chat capabilities. It includes methods for sending and receiving messages with multi-modal content (such as text, images, and audio), either as a complete set or streamed incrementally. Additionally, it allows for retrieving strongly typed services provided by the client or its underlying services.
 
-.NET libraries that provide clients for language models and services can provide an implementation of the `IChatClient` interface. Any consumers of the interface are then able to interoperate seamlessly with these models and services via the abstractions.
-
 The following sample implements `IChatClient` to show the general structure.
 
 :::code language="csharp" source="./snippets/sample-implementations/SampleChatClient.cs":::

From a2ccba541134a4b7c117b0c87f2d102d05cae6f8 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Fri, 30 May 2025 09:22:27 -0700
Subject: [PATCH 5/6] Update docs/ai/advanced/sample-implementations.md

Co-authored-by: Rageking8 <106309953+Rageking8@users.noreply.github.com>
---
 docs/ai/advanced/sample-implementations.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/ai/advanced/sample-implementations.md b/docs/ai/advanced/sample-implementations.md
index cd0bf2444da25..76b258120a7c2 100644
--- a/docs/ai/advanced/sample-implementations.md
+++ b/docs/ai/advanced/sample-implementations.md
@@ -7,7 +7,7 @@ ms.date: 05/28/2025
 
 # Sample implementations of IChatClient and IEmbeddingGenerator
 
-.NET libraries that provide clients for language models and services can provide an implementations of the <xref:Microsoft.Extensions.AI.IChatClient> and <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interfaces. Any consumers of the interfaces are then able to interoperate seamlessly with these models and services via the abstractions.
+.NET libraries that provide clients for language models and services can provide implementations of the <xref:Microsoft.Extensions.AI.IChatClient> and <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interfaces. Any consumers of the interfaces are then able to interoperate seamlessly with these models and services via the abstractions.
 
 ## The `IChatClient` interface
 

From 7b5cfdb32d45a4cdf554fc08b7bd5a3cc94f8c68 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Mon, 23 Jun 2025 10:24:00 +0200
Subject: [PATCH 6/6] use package version 9.6

---
 .../snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
index a5e809fa597f1..815287e5328bb 100644
--- a/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
+++ b/docs/ai/snippets/microsoft-extensions-ai/ConsoleAI/ConsoleAI.csproj
@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
+    <PackageReference Include="Microsoft.Extensions.AI" Version="9.6.0" />
     <PackageReference Include="OllamaSharp" Version="5.1.19" />
   </ItemGroup>