Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 3.23 KB

File metadata and controls

70 lines (53 loc) · 3.23 KB
page_type sample
languages
csharp
products
dotnet
name Reference implementations of MEAI interfaces
urlFragment meai-interface-implementations

Microsoft.Extensions.AI - Abstraction Examples

This project contains a set of samples with reference implementations for the interfaces included in the Microsoft.Extensions.AI.Abstractions and Microsoft.Extensions.AI NuGet packages.

Prerequisites

Quick Start

Visual Studio

  1. Open the AbstractionImplementationExamples.sln solution.
  2. Set AbstractionImplementationExamples as the startup project.
  3. Press F5.

Visual Studio Code

  1. Open your terminal

  2. Navigate to the AbstractionImplementationExamples project directory

  3. Run the application using dotnet run

    dotnet run
    

Test your application

  1. When the application starts, select Choose sample.
  2. Select one of the samples from the dropdown to run it.
  3. After the selected sample runs, you can choose to run another sample or select Quit to stop the application.

Reference implementations

The following are a set of reference implementations of the interfaces provided by Microsoft.Extensions.AI.Abstractions package.

Implementation Description
SampleChatClient Sample implementation of IChatClient interface.
SampleEmbeddingGenerator Sample implementation of IEmbeddingGenerator interface.
LoggingChatClient Sample implementation of DelegatingChatClient that extends IChatClient with logging functionality.
LoggingEmbeddingGenerator Sample implementation of DelegatingEmbeddingGenerator that extends IEmbeddingGenerator with logging functionality.

Examples

Example Description
Chat Use IChatClient to send and receive chat messages
Chat + Conversation History Use IChatClient alongside conversation history to send and receive chat messages
Streaming Use IChatClient to send and receive a stream of chat messages
Caching Use prompt caching middleware
OpenTelemetry Use OpenTelemetry middleware
Tool Calling Use tool calling middleware
Middleware Use prompt caching, OpenTelemetry and tool calling middleware
Dependency Injection Register an IChatClient and middleware using Dependency Injection
Text Embedding Use text embedding generator
Text Embedding + Caching Use text embedding generator with caching middleware
Logging Chat Client Use LoggingChatClient implementation
Logging Embedding Generator Use LoggingEmbeddingGenerator implementation