Skip to content

Latest commit

 

History

History

AIExtensions.Sample.ChatPlayground

README.md

AI Chat Playground

A .NET MAUI sample for comparing Apple Intelligence, Windows AI, Gemini Nano, Azure OpenAI, and offline Replay through the same chat UI. It runs on Android, iOS, Mac Catalyst, and Windows (not native macOS); providers vary by platform.

What you can try

Chat, Embeddings, and Images have separate providers and capabilities.

Chat

Provider Text Image input Tools Structured JSON
Apple Intelligence iOS / Mac Catalyst 26+ on supported hardware OS 27+ with a ready vision model Supported Supported
Windows AI Windows 11 24H2+ on supported Copilot+ hardware Not supported Not supported Supported
Gemini Nano Android API 26+ on supported AICore hardware In-memory images Not supported Not supported
Azure OpenAI Configured Responses API deployment Supported by compatible deployments Supported by compatible deployments Supported by compatible deployments
Replay Recorded responses No new image input Recorded activity, no execution Recorded responses

Native chat does not fall back to Azure. Structured responses stream only when the selected provider emits incremental updates.

Chat shows the provider's model ID and auto-saves the recording locally. New replaces the recording; More loads examples or imports/exports recordings. Replay works offline; switch to a live provider to continue chatting. Controls reflect provider capabilities. Uncheck tools or choose None to disable calls. Switching providers preserves your Structured JSON preference, but providers that opt out receive plain-text requests and their responses display as text.

Embeddings

Generate text vectors, index imported documents, and search their content.

Provider Text vectors Document indexing Semantic search
Apple NaturalLanguage Supported with the language asset Supported Supported
Azure OpenAI Configured embedding deployment Supported Supported
Windows on-device Not supported Not supported Not supported
Android on-device Not supported Not supported Not supported

Image generation

Generate or edit images using a configured Azure OpenAI deployment. Chat image input does not imply image-generation support.

Provider Image generation
Apple on-device Not supported
Windows on-device Coming soon
Android on-device Not supported
Azure OpenAI Supported by the configured image deployment

Diagnostics

Each tab's Logs button toggles a local diagnostics sidebar; capture continues while hidden. It starts collapsed. In narrow windows, tap outside to dismiss it.

Logs and completed spans are grouped by trace, including MEAI/Apple tool events. Apple callbacks retain the request's trace/span. Chat and embeddings emit spans; the pinned MEAI version provides image logging only. Model/usage data come from the provider. Payload logging and sensitive telemetry are disabled, but exceptions may contain sensitive data. Diagnostics are not exported automatically.

Run the sample

Use the repository's pinned .NET 10 SDK and matching MAUI workload. Run the following commands from the repository root.

Apple

Apple builds require Xcode 27. For Mac Catalyst:

dotnet run --project samples/AIExtensions.Sample.ChatPlayground/AIExtensions.Sample.ChatPlayground.csproj \
  -f net10.0-maccatalyst27.0 -p:UseXcode27Preview=true

Use net10.0-ios27.0 for iOS and select a device with --device <device-id>. Use --list-devices to list available targets. Enable Apple Intelligence and install the English sentence-embedding asset for the corresponding features; the asset may be absent on simulators.

Windows

dotnet run --project samples\AIExtensions.Sample.ChatPlayground\AIExtensions.Sample.ChatPlayground.csproj -f net10.0-windows10.0.19041.0

Keep the Windows sample MSIX-packaged for on-device AI. It bundles an experimental Windows App SDK runtime while the library uses stable APIs. See the Windows AI language models guide for hardware, capability, packaging, and access requirements.

Android

The Android app requires API 26+ and supported AICore hardware/configuration for Gemini Nano. It supports text/image chat, not tools or structured JSON. The first request never downloads assets: explicitly enumerate GeminiNanoChatClient.DownloadModelAsync after a download decision and query status again before chatting. There is no download UI or automatic cloud fallback. See the Android guide.

dotnet run --project samples/AIExtensions.Sample.ChatPlayground/AIExtensions.Sample.ChatPlayground.csproj \
  -f net10.0-android --device <device-id>

Configure Azure OpenAI

Azure is optional. On-device providers and Replay need no cloud credentials. Configure an endpoint (typically ending in /openai/v1/), a key, and only the deployments you want to use. The project uses user-secrets ID 2727d4aa-a3a5-484b-9447-91604761972b. From the repository root:

$project = "samples\AIExtensions.Sample.ChatPlayground\AIExtensions.Sample.ChatPlayground.csproj"
dotnet user-secrets set "AI:Endpoint" "https://<resource>.openai.azure.com/openai/v1/" --project $project
dotnet user-secrets set "AI:ApiKey" "<key>" --project $project
dotnet user-secrets set "AI:DeploymentName" "<chat-deployment>" --project $project
dotnet user-secrets set "AI:ImageDeploymentName" "<image-deployment>" --project $project
dotnet user-secrets set "AI:EmbeddingDeploymentName" "<embedding-deployment>" --project $project

AI:DeploymentName enables Chat, AI:EmbeddingDeploymentName enables Embeddings, and AI:ImageDeploymentName enables Images and Chat's image-generation tool for providers that support tool calling. The endpoint and key are required only when at least one Azure deployment is configured.

Debug builds embed your local user secrets. Do not distribute these builds or commit credentials. Azure prompts, images, and indexed text may leave the device and incur charges. Recordings may also contain sensitive data; review them before sharing.