Method AddOnnxChat
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.
public static EdgeBuilder AddOnnxChat(this EdgeBuilder builder, ChatPreset preset, Action<EdgeChatOptions>? configure = null, Action<ChatClientBuilder>? pipeline = null)
Parameters
builderEdgeBuilderThe Qavren.Edge builder.
presetChatPresetRequired. There is no default - see ChatPresets.
configureAction<EdgeChatOptions>Configures this registration's EdgeChatOptions.
pipelineAction<ChatClientBuilder>The MEAI pipeline over the client.
Returns
- EdgeBuilder
The same builder.
Exceptions
- ArgumentNullException
builderorpresetis null.
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.
public static EdgeBuilder AddOnnxChat(this EdgeBuilder builder, string name, ChatPreset preset, Action<EdgeChatOptions>? configure = null, Action<ChatClientBuilder>? pipeline = null)
Parameters
builderEdgeBuilderThe Qavren.Edge builder.
namestringThe service key.
presetChatPresetRequired. There is no default.
configureAction<EdgeChatOptions>Configures this registration's EdgeChatOptions.
pipelineAction<ChatClientBuilder>The MEAI pipeline over the client.
Returns
- EdgeBuilder
The same builder.
Exceptions
- ArgumentNullException
builderorpresetis null.- ArgumentException
nameis null or whitespace.