Skip to content

[AI] Windows Copilot Runtime (Phi Silica) support for Essentials.AI#33605

Draft
mattleibow wants to merge 18 commits intomainfrom
dev/ai-windows
Draft

[AI] Windows Copilot Runtime (Phi Silica) support for Essentials.AI#33605
mattleibow wants to merge 18 commits intomainfrom
dev/ai-windows

Conversation

@mattleibow
Copy link
Copy Markdown
Member

@mattleibow mattleibow commented Jan 19, 2026

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Summary

Adds Windows Copilot Runtime (Phi Silica) support to Microsoft.Maui.Essentials.AI, enabling on-device AI capabilities through the Microsoft.Extensions.AI abstractions on Windows.

New Components

Component Description
PhiSilicaChatClient Full IChatClient implementation for Windows Copilot Runtime — synchronous & streaming responses, lazy model init, cancellation support, middleware compatible
PhiSilicaModelFactory Internal model availability checking and lazy initialization with proper disposal
PhiSilicaExtensions LanguageModel.AsIChatClient() extension method
AppContentIndexerSearchService ISemanticSearchService using Windows AppContentIndexer — OS handles embeddings internally

Capabilities

Feature Status
Chat Completion ✅ Via GetResponseAsync() (streaming internally)
Streaming Responses ⚠️ Returns full response as single update (Windows API limitation)
System Prompts ✅ Via LanguageModel.CreateContext()
Temperature / TopK / TopP ✅ Supported
Semantic Search ✅ Via AppContentIndexer
Function/Tool Calling ❌ Not available in Phi Silica API
Structured JSON Output ❌ Not available — uses PromptBasedSchemaClient middleware

Sample App Changes

The Essentials.AI.Sample now uses Phi Silica on Windows (on-device) and falls back to OpenAI on other platforms. PromptBasedSchemaClient middleware and DisplayName attributes replace JsonPropertyName for cross-platform schema compatibility.

Dependencies

Package Version
Microsoft.WindowsAppSDK 2.0.0-experimental6
Microsoft.Web.WebView2 1.0.3650.58

Test Coverage

  • PhiSilicaChatClientTests — instantiation and metadata verification

Requirements

  • Windows 10 version 26100.0+ with Copilot Runtime enabled
  • Packaged app deployment (MSIX)

@mattleibow mattleibow force-pushed the dev/ai-windows branch 3 times, most recently from 04c4caa to 7e57668 Compare January 19, 2026 20:50
@mattleibow mattleibow changed the title [WIP] Windows AI [Feature] Add Microsoft.Maui.Essentials.AI - Phi Silica Jan 19, 2026
@mattleibow mattleibow changed the title [Feature] Add Microsoft.Maui.Essentials.AI - Phi Silica [Feature] Add Microsoft.Maui.Essentials.AI - Windows AI / Phi Silica Jan 19, 2026
@mattleibow mattleibow force-pushed the dev/ai-windows branch 2 times, most recently from 0efd5f5 to 583fb81 Compare February 13, 2026 10:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 33605

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 33605"

mattleibow and others added 8 commits March 26, 2026 04:10
- New LandmarkDetailPage with AI travel tips, similar destinations, tags
- Semantic search bar on LandmarksPage with debounced filtering
- ISemanticSearchService abstraction with EmbeddingSearchService and AppContentIndexerSearchService
- Refactored DataService to use ISemanticSearchService instead of IEmbeddingGenerator
- TaggingService switched to plaintext comma-separated parsing
- TravelPlannerExecutor uses prompt-based JSON instead of structured output
- TripPlanningPage auto-starts itinerary generation (no initial state)
- Merged LandmarkTripView into TripPlanningPage, deleted unused views
- Removed NonFunctionInvokingChatClient reference
- Language picker moved to LandmarkDetailPage

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix navigation crash: add missing Gray700 color to Colors.xaml
- Fix gradient overlays: remove broken BoxView global style, use transparent-white gradients
- Replace SearchBar with borderless Entry, remove native border/focus ring on MacCatalyst
- Edge-to-edge horizontal scrollers with aligned padding
- Scrolling gradient + solid background pattern on detail and trip planning pages
- Safe area: use SafeAreaEdges=None on root Grids, Container on back buttons
- Debounced search with Timer instead of per-keystroke async work
- Use IDispatcher instead of MainThread.BeginInvokeOnMainThread
- Only-once AI initialization on LandmarkDetailPage
- Migrate BackgroundColor to Background across pages and views
- Fix null dereference warnings in DataService

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… Bunaken landmark

- PromptBasedSchemaClient middleware for prompt-based structured output
- Fixed chat bubble alignment and scroll-to-end on Windows
- Removed LanguagePreferenceService — language passed via navigation
- Added Temperature for creative agents (0.8) and travel tips (0.9)
- Fixed WeatherService locale issue (InvariantCulture)
- Added weather display to LandmarkDetailPage
- Map placeholder on Windows (OnPlatform)
- TravelPlanResult uses short JsonPropertyName for SLM reliability
- StreamingResponseHandler passthrough mode + 7 unit tests
- Added Bunaken Marine Park (Manado, Indonesia) landmark
- Fixed agent instruction examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tenatedText)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow mattleibow changed the base branch from main to dev/ai-sample-improvements March 26, 2026 02:15
@mattleibow mattleibow changed the title [Feature] Add Microsoft.Maui.Essentials.AI - Windows AI / Phi Silica [AI] Windows Copilot Runtime (Phi Silica) support for Essentials.AI Mar 26, 2026
PromptBasedSchemaClient reads DisplayName for prompt-based JSON schema
generation, which works across all platforms including Phi Silica.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow and others added 5 commits March 26, 2026 04:29
DisplayName does not work on properties for JSON schema generation —
it only applies at the class/type level. JsonPropertyName is needed
for PromptBasedSchemaClient to emit the correct short property names.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce AI capabilities for Windows platform including:

Core Components:
- PhiSilicaChatClient: Chat completion client using Windows Copilot
  Runtime (Phi Silica) with streaming support via IChatClient
- PhiSilicaEmbeddingGenerator: Text embedding generator using
  LanguageModel.GenerateEmbeddingVectorAsync via IEmbeddingGenerator
- PhiSilicaExtensions: Convenience methods to convert LanguageModel
  to IChatClient and IEmbeddingGenerator
- (internal) PhiSilicaModelFactory: Model availability checking and
  lazy initialization with proper disposal handling

Samples:
- Update Essentials.AI.Sample to use Phi Silica on Windows,
  falling back to OpenAI on other platforms
- Configure packaged app deployment for Windows AI API access

Tests:
- Unit tests for PhiSilicaChatClient construction and metadata
- Unit tests for PhiSilicaEmbeddingGenerator construction and metadata

Dependencies:
- Update Windows App SDK to 2.0.0-experimental4 (required for AI APIs)
- Update WebView2 to 1.0.3650.58

Requires Windows 10.0.26100.0+ with Copilot Runtime support enabled.
… sample improvements

- Updated WinAppSDK from experimental4 to experimental6
- Fixed PhiSilicaChatClient streaming using shared StreamingResponseHandler
- Removed PhiSilicaEmbeddingGenerator (LLM token embeddings unsuitable for similarity)
- Added ISemanticSearchService abstraction with EmbeddingSearchService and AppContentIndexerSearchService
- New LandmarkDetailPage with AI travel tips, similar destinations, semantic search
- Refactored DataService to use ISemanticSearchService
- TaggingService switched to plaintext parsing for cross-platform compatibility
- TripPlanningPage auto-starts itinerary generation
- Fixed device test infrastructure (appxmanifest, PublicAPI, test runner script)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dmark

- PromptBasedSchemaClient middleware converts JSON schema to prompt-based instructions for Phi Silica
- Strips markdown code fences from non-streaming responses
- Fixed chat bubble alignment on Windows (Grid wrapper for CollectionView items)
- Fixed chat scroll-to-end (DispatchDelayed + MakeVisible)
- Removed LanguagePreferenceService — language passed as navigation parameter
- Added Temperature (0.8-0.9) for creative agents/tips
- Fixed WeatherService locale issue (InvariantCulture for coordinates)
- Added weather display to LandmarkDetailPage
- Map placeholder on Windows (OnPlatform swap)
- TravelPlanResult uses short JsonPropertyName to prevent SLM misspelling
- ActivityKind enum prompt-enforced (no attribute changes needed)
- StreamingResponseHandler: optional chunker (passthrough mode for pre-chunked models)
- Added 7 passthrough unit tests for StreamingResponseHandler
- Added Bunaken Marine Park (Manado, Indonesia) as new landmark
- Fixed ItineraryWorkflow agent instruction examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
File-link PromptBasedSchemaClient from the sample app into the device
tests project (Windows only). Add PhiSilicaSchemaClient wrapper that
chains PromptBasedSchemaClient → PhiSilicaChatClient, and derive
PhiSilicaChatClientJsonSchemaTests from the shared base class.

Skip the 'without schema' tests since Phi Silica requires prompt-based
schema rewriting. Embedding tests remain excluded for Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow and others added 3 commits March 26, 2026 09:29
Revert Versions.props WinAppSDK (1.8.251106002) and WebView2
(1.0.3179.45) to main values so the rest of the repo is unaffected.

Override MicrosoftWindowsAppSDKPackageVersion to 2.0.0-experimental6
only in Essentials.AI.csproj and the AI sample csproj — this scopes
the experimental dependency to the AI projects without breaking
customers or other MAUI libraries.

Remove nuget.org from NuGet.config — the experimental package resolves
from the existing internal feeds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…props

Move the per-project MicrosoftWindowsAppSDKPackageVersion overrides
into a shared Directory.Build.props at src/AI/. All AI projects
(library, sample, device tests) pick it up through MSBuild walk-up.

The sample no longer has a direct WinAppSDK PackageReference — it
receives the dependency transitively through Essentials.AI.

Chain: src/AI/samples/Directory.Build.props -> src/AI/Directory.Build.props -> root

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add PhiSilicaChatClientFunctionCallingTests (base class derivation)
and PhiSilicaChatClientValidationTests (adapted from Apple tests).

Packaged run on Copilot+ PC: 44/44 passed, 0 failed, 0 skipped.
FunctionCalling/JsonSchema/Validation tests need longer runtime
(each test makes real Phi Silica LLM calls).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Base automatically changed from dev/ai-sample-improvements to main April 2, 2026 14:09
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.

1 participant