Class BowireAiServiceCollectionExtensions

Namespace
Kuestenlogik.Bowire.Ai
Assembly
Kuestenlogik.Bowire.Ai.dll

DI helpers for the optional Kuestenlogik.Bowire.Ai package (#25). Idempotent — re-calling AddBowireAi(IServiceCollection, IConfiguration, Action<BowireAiOptions>?) is a no-op rather than registering a duplicate.

public static class BowireAiServiceCollectionExtensions
Inheritance
BowireAiServiceCollectionExtensions
Inherited Members

Methods

AddBowireAi(IServiceCollection, IConfiguration, Action<BowireAiOptions>?)

Register an Microsoft.Extensions.AI.IChatClient against the provider id in Bowire:Ai:ProviderId. Default is Ollama at http://localhost:11434 (auto-detected via GET /api/ai/probe-local); LM Studio works through the same OllamaSharp client because the wire shape matches. Cloud providers (#25 Phase 3) register their own Microsoft.Extensions.AI.IChatClient implementation behind the same abstraction.

public static IServiceCollection AddBowireAi(this IServiceCollection services, IConfiguration configuration, Action<BowireAiOptions>? configure = null)

Parameters

services IServiceCollection
configuration IConfiguration
configure Action<BowireAiOptions>

Returns

IServiceCollection

Remarks

Embedded-host override. If the host already registered an IChatClient before calling AddBowireAi(IServiceCollection, IConfiguration, Action<BowireAiOptions>?), Bowire uses that one and skips its own factory. That's the natural integration point: a host with existing AI infrastructure (Microsoft.Extensions.AI.OpenAI, Azure OpenAI, a custom in-house gateway) routes Bowire's chat calls through its already-configured client. The settings dialog's "AI" tab still renders, but the save path becomes a no-op tagged "host-managed" so the user understands the workbench can't swap a provider the host owns.

Config overlay precedence (#63). Effective options layer in this order, low-to-high: BowireAiOptions defaults → Bowire:Ai section (env vars / CLI flags via IConfiguration) → configure callback → user-config file (ai-config.json). Disk wins because it represents an explicit user choice from the Settings UI; a temporary CLI flag never silently overwrites that choice.