Skip to content

[dotnet-ai] MEAI chat integration #227

Description

@luisquintanilla

Parent Issue

Part of the dotnet-ai plugin proposal: #225

Summary

Add the meai-chat-integration skill to the dotnet-ai plugin.

This skill guides developers through integrating LLM chat capabilities into .NET applications using Microsoft.Extensions.AI (MEAI) and the IChatClient abstraction. It is the foundation layer that most other AI skills build upon.

What This Skill Covers

  • IChatClient setup with any provider (OpenAI, Azure OpenAI, Ollama, etc.)
  • ChatClientBuilder middleware pipelineUseFunctionInvocation(), UseOpenTelemetry(), UseDistributedCache()
  • Streaming via GetStreamingChatCompletionAsync()
  • Structured output with GetResponseAsync<T>() for typed JSON responses
  • Retry/resilience via Microsoft.Extensions.Http.Resilience and StandardResilienceHandler
  • Model pinning with ChatOptions.ModelId
  • Token cost awareness — extracting Usage from ChatResponse
  • Token counting and tokenizer selection — using Microsoft.ML.Tokenizers for context window management and text truncation (detailed API in references/tokenizers.md)
  • Output validation — checking FinishReason for truncation

What This Skill Does NOT Cover

  • Embeddings (use meai-embeddings)
  • Agent workflows / tool calling (use agentic-workflow)
  • ML.NET classical ML (use mlnet)
  • Running pre-trained ONNX models (use onnx-runtime-inference)

Reference Files

File Purpose
references/tokenizers.md Microsoft.ML.Tokenizers API — all 8 tokenizer types (Tiktoken, BPE, SentencePiece, Llama, BERT, WordPiece, CodeGen, Phi2), token counting, truncation, encoding/decoding. Used by this skill for context window management and also referenced by data-ingestion-pipeline, onnx-runtime-inference, and rag-pipeline for their tokenization needs.

Files

plugins/dotnet-ai/skills/meai-chat-integration/
  SKILL.md
  references/
    tokenizers.md
tests/dotnet-ai/meai-chat-integration/eval.yaml

Eval Scenarios

  1. ASP.NET Core chat endpoint — prompt asks to add chat to an API; expects IChatClient with DI registration, streaming, and middleware pipeline

Key Packages

  • Microsoft.Extensions.AI (core)
  • Microsoft.ML.Tokenizers (token counting and context window management)
  • Provider: OpenAI, Azure.AI.OpenAI, or OllamaSharp

Dependencies

Requires the plugin scaffold (sub-issue #1) to be merged first.

Acceptance Criteria

  • SKILL.md has valid YAML frontmatter with name and description
  • Covers IChatClient setup, streaming, structured output, middleware, resilience
  • references/tokenizers.md covers all 8 tokenizer types, CountTokens, EncodeToIds, Decode, GetIndexByTokenCount
  • eval.yaml has at least one scenario that validates the skill
  • Does not duplicate content from other skills

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions