Class: Raif::PromptStudioComparisonBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/raif/prompt_studio_comparison_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ PromptStudioComparisonBuilder

Returns a new instance of PromptStudioComparisonBuilder.



11
12
13
# File 'lib/raif/prompt_studio_comparison_builder.rb', line 11

def initialize(record)
  @record = record
end

Class Method Details

.build(record) ⇒ Object

Attempts to rebuild the prompt from current code for a given record. Returns a hash with the rendered prompts and any warnings.



7
8
9
# File 'lib/raif/prompt_studio_comparison_builder.rb', line 7

def self.build(record)
  new(record).build
end

Instance Method Details

#buildObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/raif/prompt_studio_comparison_builder.rb', line 15

def build
  {
    original_prompt: original_prompt,
    original_system_prompt: original_system_prompt,
    current_prompt: current_prompt,
    current_system_prompt: current_system_prompt,
    prompt_changed: changed?(original_prompt, current_prompt),
    system_prompt_changed: changed?(original_system_prompt, current_system_prompt),
    has_stale_references: has_stale_references?,
    warnings: warnings
  }
end