Class: Observ::DatasetRunItem
Instance Method Summary
collapse
Methods included from Scoreable
#manual_score, #score_for, #score_summary, #scored?
Instance Method Details
#actual_output ⇒ Object
49
50
51
|
# File 'app/models/observ/dataset_run_item.rb', line 49
def actual_output
trace&.output
end
|
#cost ⇒ Object
61
62
63
|
# File 'app/models/observ/dataset_run_item.rb', line 61
def cost
trace&.total_cost
end
|
#duration_ms ⇒ Object
69
70
71
|
# File 'app/models/observ/dataset_run_item.rb', line 69
def duration_ms
trace&.duration_ms
end
|
#expected_output ⇒ Object
45
46
47
|
# File 'app/models/observ/dataset_run_item.rb', line 45
def expected_output
dataset_item.expected_output
end
|
#failed? ⇒ Boolean
26
27
28
|
# File 'app/models/observ/dataset_run_item.rb', line 26
def failed?
error.present?
end
|
#failing_scores_count ⇒ Object
78
79
80
|
# File 'app/models/observ/dataset_run_item.rb', line 78
def failing_scores_count
scores.where("value < 0.5").count
end
|
41
42
43
|
# File 'app/models/observ/dataset_run_item.rb', line 41
def input
dataset_item.input
end
|
#output_matches? ⇒ Boolean
54
55
56
57
58
|
# File 'app/models/observ/dataset_run_item.rb', line 54
def output_matches?
return nil if expected_output.blank? || actual_output.blank?
normalize_for_comparison(expected_output) == normalize_for_comparison(actual_output)
end
|
#passing_scores_count ⇒ Object
DatasetRunItem-specific score helpers
74
75
76
|
# File 'app/models/observ/dataset_run_item.rb', line 74
def passing_scores_count
scores.where("value >= 0.5").count
end
|
#pending? ⇒ Boolean
30
31
32
|
# File 'app/models/observ/dataset_run_item.rb', line 30
def pending?
trace_id.nil? && error.nil?
end
|
#status ⇒ Object
34
35
36
37
38
|
# File 'app/models/observ/dataset_run_item.rb', line 34
def status
return :failed if failed?
return :succeeded if succeeded?
:pending
end
|
#succeeded? ⇒ Boolean
22
23
24
|
# File 'app/models/observ/dataset_run_item.rb', line 22
def succeeded?
trace_id.present? && error.blank?
end
|
#tokens ⇒ Object
65
66
67
|
# File 'app/models/observ/dataset_run_item.rb', line 65
def tokens
trace&.total_tokens
end
|