Class ChatOnnxEdgeBuilderExtensions
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-200OrtEnvtask, 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 toservices.AddChatClient.Registration goes through MEAI's own
AddChatClientand not a hand-rolledIChatClientdescriptor, because that is the descriptor Agent Framework and Semantic Kernel resolve, and because its factory isChatClientBuilder.Build- so the pipeline is constructed lazily from the app's provider and the order of builder calls does not matter.AddChatClientandAddKeyedChatClientlive in theMicrosoft.Extensions.DependencyInjectionnamespace, notMicrosoft.Extensions.AI(plan adjustment 10).Returns EdgeBuilder rather than
ChatClientBuilder, matchingAddOnnxEmbeddingsand the rest of the suite's chaining idiom; the MEAI pipeline is the optionalpipelinecallback. Remember MEAI's ordering contract:ChatClientBuilder.Buildapplies factories in REVERSE, so the FIRSTUse()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.Startedon a 1.241 GB transfer also blocks everyIEdgeDatabase.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'sWarmUpSessionAtStartupregisters with a bareAddSingletonand gets duplicate order-220 tasks when called twice; sub-project 4 does not repeat that.