Table of Contents

Class ChatOnnxEdgeBuilderExtensions

Namespace
Qavren.Edge.Chat
Assembly
Qavren.Edge.Chat.Onnx.dll

Registers on-device chat on the Qavren.Edge builder.

public static class ChatOnnxEdgeBuilderExtensions
Inheritance
ChatOnnxEdgeBuilderExtensions
Inherited Members

Methods

AddOnnxChat(EdgeBuilder, ChatPreset, Action<EdgeChatOptions>?, Action<ChatClientBuilder>?)

Calls AddOnnx() (so sub-project 2's order-200 OrtEnv task, model paths, resource monitor and model store are present and correctly ordered), registers the device profile, the model host, the provisioner, the order-400 startup task, the lifecycle observer and the diagnostics contributor, then delegates to services.AddChatClient.

Registration goes through MEAI's own AddChatClient and not a hand-rolled IChatClient descriptor, because that is the descriptor Agent Framework and Semantic Kernel resolve, and because its factory is ChatClientBuilder.Build - so the pipeline is constructed lazily from the app's provider and the order of builder calls does not matter. AddChatClient and AddKeyedChatClient live in the Microsoft.Extensions.DependencyInjection namespace, not Microsoft.Extensions.AI (plan adjustment 10).

Returns EdgeBuilder rather than ChatClientBuilder, matching AddOnnxEmbeddings and the rest of the suite's chaining idiom; the MEAI pipeline is the optional pipeline callback. Remember MEAI's ordering contract: ChatClientBuilder.Build applies factories in REVERSE, so the FIRST Use() call is the OUTERMOST client.

AddOnnxChat(EdgeBuilder, string, ChatPreset, Action<EdgeChatOptions>?, Action<ChatClientBuilder>?)

Keyed registration, mirroring sub-project 1's named databases and sub-project 2's named generators. Uses AddKeyedChatClient.

RequireChatModelAtStartup(EdgeBuilder, string?)

Order 410. Faults startup with ChatModelNotProvisioned when the model is absent. It never downloads: blocking IEdgeHost.Started on a 1.241 GB transfer also blocks every IEdgeDatabase.OpenConnectionAsync.

WarmUpChatAtStartup(EdgeBuilder, string?)

Order 420. Loads the model through IChatModelHost.PreloadAsync, probes the chat template, and probes guidance when the policy is not Disabled. Off by default: it forces provisioning. It runs no generation - one token on a 1B model is 30 ms of decode on top of a 1.6 s load, and nothing about the decode loop is proven by doing it twice.

Idempotent per registration, made so by scanning the IServiceCollection for a marker record - not TryAddEnumerable, which on an enumerable service like IEdgeStartupTask would suppress every other package's task rather than a duplicate of this one. Sub-project 2's WarmUpSessionAtStartup registers with a bare AddSingleton and gets duplicate order-220 tasks when called twice; sub-project 4 does not repeat that.