Class: PromptEngine::EvalRun

Inherits:
ApplicationRecord show all
Defined in:
app/models/prompt_engine/eval_run.rb

Instance Method Summary collapse

Instance Method Details

#durationObject



18
19
20
21
# File 'app/models/prompt_engine/eval_run.rb', line 18

def duration
  return nil unless started_at && completed_at
  completed_at - started_at
end

#duration_in_wordsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/prompt_engine/eval_run.rb', line 23

def duration_in_words
  return "Not started" unless started_at
  return "Running" if running?
  return "Failed" if failed? && !completed_at

  seconds = duration
  return nil unless seconds

  if seconds < 60
    "#{seconds.round} seconds"
  elsif seconds < 3600
    "#{(seconds / 60).round} minutes"
  else
    "#{(seconds / 3600).round(1)} hours"
  end
end

#success_rateObject



13
14
15
16
# File 'app/models/prompt_engine/eval_run.rb', line 13

def success_rate
  return 0 if total_count.zero?
  (passed_count.to_f / total_count * 100).round(1)
end