fix(captain): respect configured classifier model

This commit is contained in:
aakashb95
2026-05-04 17:11:57 +05:30
parent d956a023da
commit 563be4ac2f
2 changed files with 11 additions and 2 deletions
@@ -2,14 +2,12 @@ class Captain::Llm::AssistantActionClassifierService < Llm::BaseAiService
include Integrations::LlmInstrumentation
PROMPT_VERSION = 'v1_custom_xml_precedence'.freeze
DEFAULT_MODEL = 'gpt-4.1'.freeze
MAX_CONTEXT_MESSAGES = 10
def initialize(assistant:, conversation:)
super()
@assistant = assistant
@conversation = conversation
@model = DEFAULT_MODEL
@temperature = 0.0
end
@@ -67,6 +67,17 @@ RSpec.describe Captain::Llm::AssistantActionClassifierService do
)
end
it 'uses the configured Captain model from the base LLM service' do
create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'provider/custom-model')
expect(RubyLLM).to receive(:chat).with(model: 'provider/custom-model').and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
result = service.classify(message_history: message_history, assistant_response: 'Would you like to talk to support?')
expect(result).to include('model' => 'provider/custom-model')
end
context 'when the assistant has no custom instructions' do
before do
assistant.update!(config: assistant.config.except('instructions'))