Class BowireAiRuntime
- Namespace
- Kuestenlogik.Bowire.Ai
- Assembly
- Kuestenlogik.Bowire.Ai.dll
Holds the live AI configuration + the active provider client. The Settings UI (#63) calls Update(BowireAiOptions) to swap provider / endpoint / model at runtime; Kuestenlogik.Bowire.Ai.MutableChatClient wraps this so the singleton Microsoft.Extensions.AI.IChatClient registration always dispatches to the current provider without restarting the host.
public sealed class BowireAiRuntime : IDisposable
- Inheritance
-
BowireAiRuntime
- Implements
- Inherited Members
Remarks
Provider dispatch is plugin-based. The runtime never imports
a provider SDK directly. Instead it receives the registered
IBowireAiProviderFactory list from DI and asks them
in order for a matching client. Embedded hosts that only install
Kuestenlogik.Bowire.Ai get the Ollama factory; adding
.OpenAi / .Anthropic / .Mcp registers each
additional factory. Without a matching factory the active client
stays null and POST /api/ai/chat returns 503 with
a configurable error.
Held as a singleton. Concurrent reads of Current race against Update(BowireAiOptions) intentionally — the worst-case is a single in-flight chat call landing on the previous client, which is safer than locking the chat path for the duration of a request.
Implements IDisposable so the DI container disposes the active provider client (and the inner socket-owning instance each factory hands back) on host shutdown. Update(BowireAiOptions) already disposes the prior pair on hot-swap; Dispose() covers the final shutdown leg.
Constructors
BowireAiRuntime(BowireAiOptions, IEnumerable<IBowireAiProviderFactory>?)
public BowireAiRuntime(BowireAiOptions initialOptions, IEnumerable<IBowireAiProviderFactory>? factories = null)
Parameters
initialOptionsBowireAiOptionsfactoriesIEnumerable<IBowireAiProviderFactory>
Properties
Current
The current provider client, or null when the configured provider isn't supported in this build.
public IChatClient? Current { get; }
Property Value
- IChatClient
Options
Snapshot of the current options. Returned copy — callers can't mutate the live record.
public BowireAiOptions Options { get; }
Property Value
Methods
Dispose()
public void Dispose()
Update(BowireAiOptions)
Replace the live options + rebuild the provider client. Returns the post-update snapshot so callers (config endpoint, settings dialog) can echo back the canonical state.
public BowireAiOptions Update(BowireAiOptions next)
Parameters
nextBowireAiOptions