Class: RubyLLM::Agents::Eval::EvalResult
- Inherits:
-
Object
- Object
- RubyLLM::Agents::Eval::EvalResult
- Defined in:
- lib/ruby_llm/agents/eval/eval_result.rb
Overview
Holds the result of evaluating a single test case.
Contains the test case definition, the agent’s result, the score, and any error that occurred during execution.
Instance Attribute Summary collapse
-
#agent_result ⇒ Object
readonly
Returns the value of attribute agent_result.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#execution_id ⇒ Object
readonly
Returns the value of attribute execution_id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#test_case ⇒ Object
readonly
Returns the value of attribute test_case.
Instance Method Summary collapse
- #actual ⇒ Object
- #errored? ⇒ Boolean
- #expected ⇒ Object
- #failed?(threshold = 0.5) ⇒ Boolean
-
#initialize(test_case:, agent_result:, score:, execution_id: nil, error: nil) ⇒ EvalResult
constructor
A new instance of EvalResult.
- #input ⇒ Object
- #passed?(threshold = 0.5) ⇒ Boolean
- #test_case_name ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(test_case:, agent_result:, score:, execution_id: nil, error: nil) ⇒ EvalResult
Returns a new instance of EvalResult.
13 14 15 16 17 18 19 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 13 def initialize(test_case:, agent_result:, score:, execution_id: nil, error: nil) @test_case = test_case @agent_result = agent_result @score = score @execution_id = execution_id @error = error end |
Instance Attribute Details
#agent_result ⇒ Object (readonly)
Returns the value of attribute agent_result.
11 12 13 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 11 def agent_result @agent_result end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 11 def error @error end |
#execution_id ⇒ Object (readonly)
Returns the value of attribute execution_id.
11 12 13 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 11 def execution_id @execution_id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
11 12 13 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 11 def score @score end |
#test_case ⇒ Object (readonly)
Returns the value of attribute test_case.
11 12 13 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 11 def test_case @test_case end |
Instance Method Details
#actual ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 45 def actual return nil unless agent_result if agent_result.respond_to?(:route) {route: agent_result.route} elsif agent_result.respond_to?(:content) agent_result.content else agent_result end end |
#errored? ⇒ Boolean
41 42 43 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 41 def errored? !error.nil? end |
#expected ⇒ Object
29 30 31 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 29 def expected test_case.expected end |
#failed?(threshold = 0.5) ⇒ Boolean
37 38 39 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 37 def failed?(threshold = 0.5) score.failed?(threshold) end |
#input ⇒ Object
25 26 27 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 25 def input test_case.input end |
#passed?(threshold = 0.5) ⇒ Boolean
33 34 35 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 33 def passed?(threshold = 0.5) score.passed?(threshold) end |
#test_case_name ⇒ Object
21 22 23 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 21 def test_case_name test_case.name end |
#to_h ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_llm/agents/eval/eval_result.rb', line 57 def to_h { name: test_case_name, score: score.value, reason: score.reason, passed: passed?, input: input, expected: expected, actual: actual, execution_id: execution_id, error: error&. } end |