Merge branch 'develop' into feat/assisant-overview-page
This commit is contained in:
@@ -56,11 +56,11 @@ RSpec.describe Concerns::Agentable do
|
||||
dummy_instance.agent
|
||||
end
|
||||
|
||||
it 'converts nil temperature to 0.0' do
|
||||
it 'uses default temperature when temperature is nil' do
|
||||
dummy_instance.temperature = nil
|
||||
|
||||
expect(Agents::Agent).to receive(:new).with(
|
||||
hash_including(temperature: 0.0)
|
||||
hash_including(temperature: 0.5)
|
||||
)
|
||||
|
||||
dummy_instance.agent
|
||||
|
||||
@@ -4,6 +4,26 @@ RSpec.describe Contact, type: :model do
|
||||
describe 'company auto-association' do
|
||||
let(:account) { create(:account) }
|
||||
|
||||
before { account.enable_features!(:companies) }
|
||||
|
||||
context 'when the companies feature is disabled' do
|
||||
before { account.disable_features!(:companies) }
|
||||
|
||||
it 'does not create or associate a company' do
|
||||
expect do
|
||||
create(:contact, email: 'john@acme.com', account: account)
|
||||
end.not_to change(Company, :count)
|
||||
expect(described_class.last.company).to be_nil
|
||||
end
|
||||
|
||||
it 'preserves a contact-supplied company_name' do
|
||||
contact = create(:contact, email: 'john@acme.com', account: account,
|
||||
additional_attributes: { 'company_name' => 'John Personal Co' })
|
||||
|
||||
expect(contact.reload.additional_attributes['company_name']).to eq('John Personal Co')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when creating a new contact with business email' do
|
||||
it 'automatically creates and associates a company' do
|
||||
expect do
|
||||
|
||||
@@ -93,7 +93,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do
|
||||
expect(mock_runner).to receive(:run).with(
|
||||
'I need help with my account',
|
||||
context: expected_context,
|
||||
max_turns: 100
|
||||
max_turns: 10
|
||||
)
|
||||
|
||||
service.generate_response(message_history: message_history)
|
||||
@@ -119,7 +119,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do
|
||||
expect(input.text).to eq('What does this error mean?')
|
||||
expect(input.attachments.first.source.to_s).to eq('https://example.com/error.png')
|
||||
expect(context[:conversation_history]).to eq([{ role: :assistant, content: 'Please share a screenshot', agent_name: nil }])
|
||||
expect(max_turns).to eq(100)
|
||||
expect(max_turns).to eq(10)
|
||||
end
|
||||
|
||||
service.generate_response(message_history: multimodal_message_history)
|
||||
@@ -147,7 +147,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do
|
||||
{ type: 'text', text: 'Here is my error screenshot' },
|
||||
{ type: 'image_url', image_url: { url: 'https://example.com/error.png' } }
|
||||
)
|
||||
expect(max_turns).to eq(100)
|
||||
expect(max_turns).to eq(10)
|
||||
end
|
||||
|
||||
service.generate_response(message_history: history_with_prior_image)
|
||||
@@ -157,7 +157,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do
|
||||
expect(mock_runner).to receive(:run) do |_input, context:, max_turns:|
|
||||
expect(context[:captain_v2_trace_input]).to include('image_url')
|
||||
expect(context[:captain_v2_trace_current_input]).to include('image_url')
|
||||
expect(max_turns).to eq(100)
|
||||
expect(max_turns).to eq(10)
|
||||
end
|
||||
|
||||
service.generate_response(message_history: multimodal_message_history)
|
||||
|
||||
@@ -39,6 +39,24 @@ RSpec.describe Captain::Llm::AssistantChatService do
|
||||
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
|
||||
end
|
||||
|
||||
it 'uses default temperature when assistant config does not include temperature' do
|
||||
expect(mock_chat).to receive(:with_temperature).with(0.5).and_return(mock_chat)
|
||||
allow(mock_chat).to receive(:ask).and_return(mock_response)
|
||||
|
||||
service = described_class.new(assistant: assistant, conversation: conversation)
|
||||
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
|
||||
end
|
||||
|
||||
it 'preserves explicit assistant config temperature' do
|
||||
assistant.update!(config: assistant.config.merge('temperature' => 1.0))
|
||||
|
||||
expect(mock_chat).to receive(:with_temperature).with(1.0).and_return(mock_chat)
|
||||
allow(mock_chat).to receive(:ask).and_return(mock_response)
|
||||
|
||||
service = described_class.new(assistant: assistant, conversation: conversation)
|
||||
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
|
||||
end
|
||||
|
||||
it 'passes channel_type to the agent session instrumentation' do
|
||||
service = described_class.new(assistant: assistant, conversation: conversation)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user