fix(captain): move false promise harness setting to account (#14823)
# Pull Request Template ## Description moves the harness to account settings rather than assistant settings ## Type of change refactor ## 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
This commit is contained in:
@@ -54,7 +54,7 @@ class Account < ApplicationRecord
|
||||
store_accessor :settings, :captain_models, :captain_features
|
||||
store_accessor :settings, :reporting_timezone
|
||||
store_accessor :settings, :keep_pending_on_bot_failure
|
||||
store_accessor :settings, :captain_auto_resolve_mode
|
||||
store_accessor :settings, :captain_auto_resolve_mode, :captain_false_promise_harness_enabled
|
||||
include AccountCaptainAutoResolve
|
||||
|
||||
has_many :account_users, dependent: :destroy_async
|
||||
|
||||
@@ -12,6 +12,7 @@ module AccountSettingsSchema
|
||||
'auto_resolve_label': { 'type': %w[string null] },
|
||||
'keep_pending_on_bot_failure': { 'type': %w[boolean null] },
|
||||
'captain_auto_resolve_mode': { 'type': %w[string null], 'enum': ['evaluated', 'legacy', 'disabled', nil] },
|
||||
'captain_false_promise_harness_enabled': { 'type': %w[boolean null] },
|
||||
'conversation_required_attributes': {
|
||||
'type': %w[array null],
|
||||
'items': { 'type': 'string' }
|
||||
|
||||
@@ -80,7 +80,7 @@ module Captain::Conversation::V1FalsePromiseHandler
|
||||
end
|
||||
|
||||
def v1_false_promise_harness_enabled?
|
||||
ActiveModel::Type::Boolean.new.cast(@assistant.config['false_promise_harness_enabled'])
|
||||
ActiveModel::Type::Boolean.new.cast(account.captain_false_promise_harness_enabled)
|
||||
end
|
||||
|
||||
def log_v1_false_promise_detection(detection)
|
||||
|
||||
@@ -62,7 +62,7 @@ RSpec.describe Captain::Conversation::ResponseBuilderJob, type: :job do
|
||||
expect(conversation.messages.last.content).to eq('Hey, welcome to Captain Specs')
|
||||
end
|
||||
|
||||
it 'does not run the false promise harness when the assistant setting is disabled' do
|
||||
it 'does not run the false promise harness when the account setting is disabled' do
|
||||
expect(Captain::Llm::AssistantFalsePromiseService).not_to receive(:new)
|
||||
|
||||
described_class.perform_now(conversation, assistant)
|
||||
@@ -70,9 +70,9 @@ RSpec.describe Captain::Conversation::ResponseBuilderJob, type: :job do
|
||||
expect(conversation.messages.last.content).to eq('Hey, welcome to Captain Specs')
|
||||
end
|
||||
|
||||
context 'when false promise harness is enabled in assistant config' do
|
||||
context 'when false promise harness is enabled in account settings' do
|
||||
before do
|
||||
assistant.update!(config: assistant.config.merge('false_promise_harness_enabled' => true))
|
||||
account.update!(settings: account.settings.merge('captain_false_promise_harness_enabled' => true))
|
||||
end
|
||||
|
||||
it 'sends the original response when the detector marks it safe' do
|
||||
|
||||
Reference in New Issue
Block a user