Class: RubyLLM::Contract::Eval::Recommendation
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Eval::Recommendation
- Includes:
- Concerns::DeepFreeze
- Defined in:
- lib/ruby_llm/contract/eval/recommendation.rb
Instance Attribute Summary collapse
-
#best ⇒ Object
readonly
Returns the value of attribute best.
-
#cost_per_call ⇒ Object
readonly
Returns the value of attribute cost_per_call.
-
#current_config ⇒ Object
readonly
Returns the value of attribute current_config.
-
#rationale ⇒ Object
readonly
Returns the value of attribute rationale.
-
#retry_chain ⇒ Object
readonly
Returns the value of attribute retry_chain.
-
#savings ⇒ Object
readonly
Returns the value of attribute savings.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(best:, retry_chain:, score:, cost_per_call:, rationale:, current_config:, savings:, warnings:) ⇒ Recommendation
constructor
A new instance of Recommendation.
- #to_dsl ⇒ Object
Constructor Details
#initialize(best:, retry_chain:, score:, cost_per_call:, rationale:, current_config:, savings:, warnings:) ⇒ Recommendation
Returns a new instance of Recommendation.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 12 def initialize(best:, retry_chain:, score:, cost_per_call:, rationale:, current_config:, savings:, warnings:) @best = deep_dup_freeze(best) @retry_chain = deep_dup_freeze(retry_chain) @score = score @cost_per_call = cost_per_call @rationale = deep_dup_freeze(rationale) @current_config = deep_dup_freeze(current_config) @savings = deep_dup_freeze(savings) @warnings = deep_dup_freeze(warnings) freeze end |
Instance Attribute Details
#best ⇒ Object (readonly)
Returns the value of attribute best.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def best @best end |
#cost_per_call ⇒ Object (readonly)
Returns the value of attribute cost_per_call.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def cost_per_call @cost_per_call end |
#current_config ⇒ Object (readonly)
Returns the value of attribute current_config.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def current_config @current_config end |
#rationale ⇒ Object (readonly)
Returns the value of attribute rationale.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def rationale @rationale end |
#retry_chain ⇒ Object (readonly)
Returns the value of attribute retry_chain.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def retry_chain @retry_chain end |
#savings ⇒ Object (readonly)
Returns the value of attribute savings.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def savings @savings end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def score @score end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
9 10 11 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 9 def warnings @warnings end |
Instance Method Details
#to_dsl ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_llm/contract/eval/recommendation.rb', line 25 def to_dsl return "# No recommendation — no candidate met the minimum score" if retry_chain.empty? if retry_chain.length == 1 && retry_chain.first.keys == [:model] "model \"#{retry_chain.first[:model]}\"" elsif retry_chain.all? { |c| c.keys == [:model] } models_str = retry_chain.map { |c| c[:model] }.join(" ") "retry_policy models: %w[#{models_str}]" else args = retry_chain.map { |c| config_to_ruby(c) }.join(",\n ") "retry_policy do\n escalate(#{args})\nend" end end |