Class: CoPlan::AutomatedPlanReviewer

Inherits:
ApplicationRecord show all
Defined in:
app/models/coplan/automated_plan_reviewer.rb

Constant Summary collapse

ACTOR_TYPE =
"cloud_persona"
AI_PROVIDERS =
%w[openai anthropic].freeze
DEFAULT_REVIEWERS =
[
  { key: "security-reviewer", name: "Security Reviewer", prompt_file: "prompts/reviewers/security.md",
    trigger_statuses: [ "considering" ], ai_model: "gpt-4o" },
  { key: "scalability-reviewer", name: "Scalability Reviewer", prompt_file: "prompts/reviewers/scalability.md",
    trigger_statuses: [ "considering", "developing" ], ai_model: "gpt-4o" },
  { key: "routing-reviewer", name: "Routing Reviewer", prompt_file: "prompts/reviewers/routing.md",
    trigger_statuses: [], ai_model: "gpt-4o" }
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_defaultsObject



28
29
30
31
32
33
34
35
36
37
# File 'app/models/coplan/automated_plan_reviewer.rb', line 28

def self.create_defaults
  DEFAULT_REVIEWERS.each do |template|
    find_or_create_by!(key: template[:key]) do |r|
      r.name = template[:name]
      r.prompt_text = File.read(CoPlan::Engine.root.join(template[:prompt_file]))
      r.trigger_statuses = template[:trigger_statuses]
      r.ai_model = template[:ai_model]
    end
  end
end

.ransackable_associations(auth_object = nil) ⇒ Object



43
44
45
# File 'app/models/coplan/automated_plan_reviewer.rb', line 43

def self.ransackable_associations(auth_object = nil)
  %w[]
end

.ransackable_attributes(auth_object = nil) ⇒ Object



39
40
41
# File 'app/models/coplan/automated_plan_reviewer.rb', line 39

def self.ransackable_attributes(auth_object = nil)
  %w[id key name enabled ai_provider ai_model created_at updated_at]
end

Instance Method Details

#triggers_on_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/coplan/automated_plan_reviewer.rb', line 47

def triggers_on_status?(status)
  trigger_statuses.include?(status.to_s)
end