Skip to content

refactor: Separate AIModel from Chat#123

Open
srebrek wants to merge 9 commits intomainfrom
refactor/separate-aimodel-and-chat
Open

refactor: Separate AIModel from Chat#123
srebrek wants to merge 9 commits intomainfrom
refactor/separate-aimodel-and-chat

Conversation

@srebrek
Copy link
Collaborator

@srebrek srebrek commented Mar 5, 2026

This Pr decouples AIModel from the Chat by removing ModelInstance property and relying on in-memory ModelRegistry. Removed Backend from the chat as well, as it is a model property not chat.

Removed WithModel(AIModel) and WithModel<TModel>() to standarize flow eg. register model -> use it, instead of implicitly creating it or registering without any warning. Due to ModelId constants (that I removed in recent PRs 🙃) the usage is nearly the same (with built-in or hardcoded model). Dynamicly loaded models have to be registered every time the aplication starts (added an exapmle how it works).

Add GenericImageGenerationCloudModel to enable dynamic cloud models to be created with correct interface. I am planning to switch from interfaces to dynamic dictionary<abaility, handler> to avoid GenericTTSImageGenerationReasoning...SomethingElseCloudModel.

Breaking Changes:

  • WithModel(AIModel) and WithModel<TModel>() removed from IChatBuilderEntryPoint. Use WithModel(string modelId) with constants from Models.* or a registered model ID.
  • WithBackend(BackendType) removed from IChatConfigurationBuilder. Backend is now derived from the model - set it by choosing the appropriate model.
  • Chat.Backend and Chat.ModelInstance properties removed.
  • Some changes and fixes to SQL/SQLite databases
  • Removed some obsolete methods

@wisedev-pstach
Copy link
Contributor

Can changes be extended also for AgentContext?
And btw, drop sql/db changes, whole infra will be removed from this package soon - no point of updating it

wisedev-pstach
wisedev-pstach previously approved these changes Mar 12, 2026
- examples use const model ids instead of magic strings
- add flux id (the approach in examples will be refactored)
@srebrek
Copy link
Collaborator Author

srebrek commented Mar 13, 2026

Can changes be extended also for AgentContext? And btw, drop sql/db changes, whole infra will be removed from this package soon - no point of updating it

Applied the changes to the AgentContext. About the db changes... those changes are already made. If this isn't necessary I wouldn't reverse them. The next PR will aim to decouple Infrastructure from Services.

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.

2 participants