Skip to content

refactor: Add IChatClient with transient lifetime for all providers#116

Merged
kaspermarstal merged 2 commits intomainfrom
chatclient-transient
Feb 19, 2025
Merged

refactor: Add IChatClient with transient lifetime for all providers#116
kaspermarstal merged 2 commits intomainfrom
chatclient-transient

Conversation

@kaspermarstal
Copy link
Contributor

@kaspermarstal kaspermarstal commented Feb 19, 2025

IChatClients are usually registered as singletons, but transient lifetimes are necessary for us because the user can change base address or api key at runtime and these settings can only be passed via constructors.

The performance overhead of creating new instances is negligible, however, because execution time is completely dominated by model response time.

The PR adds a bit of redundant service configuration code but makes provider configuration via UI more robust (by always reading base address, api key, and model name from provider configuration), easier to reason about, and easier to maintain.

@kaspermarstal kaspermarstal merged commit 01fab1d into main Feb 19, 2025
4 checks passed
@kaspermarstal kaspermarstal deleted the chatclient-transient branch April 9, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant