# Pull Request Template ## Description Captain v1 does not have access to contact attributes. Added a toggle to let user choose if they want contact information available to Captain. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## 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. Specs and locally <img width="1924" height="740" alt="CleanShot 2026-03-19 at 18 48 19@2x" src="https://github.com/user-attachments/assets/353cfeaa-cd58-40eb-89e7-d660a1dc1185" /> ![Uploading CleanShot 2026-03-19 at 18.53.26@2x.png…]() ## 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
57 lines
1.4 KiB
Ruby
57 lines
1.4 KiB
Ruby
module Concerns::Agentable
|
|
extend ActiveSupport::Concern
|
|
|
|
def agent
|
|
Agents::Agent.new(
|
|
name: agent_name,
|
|
instructions: ->(context) { agent_instructions(context) },
|
|
tools: agent_tools,
|
|
model: agent_model,
|
|
temperature: temperature.to_f || 0.7,
|
|
response_schema: agent_response_schema
|
|
)
|
|
end
|
|
|
|
def agent_instructions(context = nil)
|
|
enhanced_context = prompt_context
|
|
|
|
if context
|
|
state = context.context[:state] || {}
|
|
config = state[:assistant_config] || {}
|
|
enhanced_context = enhanced_context.merge(
|
|
conversation: state[:conversation] || {},
|
|
contact: config['feature_contact_attributes'].present? ? state[:contact] : nil,
|
|
campaign: state[:campaign] || {}
|
|
)
|
|
end
|
|
|
|
Captain::PromptRenderer.render(template_name, enhanced_context.with_indifferent_access)
|
|
end
|
|
|
|
private
|
|
|
|
def agent_name
|
|
raise NotImplementedError, "#{self.class} must implement agent_name"
|
|
end
|
|
|
|
def template_name
|
|
self.class.name.demodulize.underscore
|
|
end
|
|
|
|
def agent_tools
|
|
[] # Default implementation, override if needed
|
|
end
|
|
|
|
def agent_model
|
|
InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_MODEL')&.value.presence || LlmConstants::DEFAULT_MODEL
|
|
end
|
|
|
|
def agent_response_schema
|
|
Captain::ResponseSchema
|
|
end
|
|
|
|
def prompt_context
|
|
raise NotImplementedError, "#{self.class} must implement prompt_context"
|
|
end
|
|
end
|