Files
chatwoot/lib/llm/feature_router.rb
Aakash BakhleandGitHub 83dda621c5 feat: default new accounts to captain v2 (#14917)
# Pull Request Template

## Description

defaults new accounts to captain v2

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.

locally and specs

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules
2026-07-07 16:21:51 +05:30

40 lines
1.2 KiB
Ruby

module Llm::FeatureRouter
class UnknownFeatureError < StandardError; end
CAPTAIN_V2_ASSISTANT_MODEL = 'gpt-5.2'.freeze
class << self
def resolve(feature:, account: nil)
feature_key = feature.to_s
raise UnknownFeatureError, "Unknown LLM feature: #{feature_key}" unless Llm::Models.feature?(feature_key)
model = account_model_override(account, feature_key)
source = model.present? ? :account_override : :default
model ||= captain_v2_assistant_model(account, feature_key)
model ||= Llm::Models.default_model_for(feature_key)
{
feature: feature_key,
provider: Llm::Models.provider_for(model),
model: model,
source: source
}
end
private
def account_model_override(account, feature_key)
model = account&.captain_models&.[](feature_key).presence
return unless model
return model if Llm::Models.valid_model_for?(feature_key, model)
end
def captain_v2_assistant_model(account, feature_key)
return unless feature_key == 'assistant'
return unless account&.feature_enabled?('captain_integration_v2')
CAPTAIN_V2_ASSISTANT_MODEL
end
end
end