Class: RubyLLM::Thinking::Controls

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/thinking.rb

Overview

:nodoc: all

Constant Summary collapse

PREFERRED_EFFORTS =
%w[medium low minimal high xhigh max].freeze

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Controls

Returns a new instance of Controls.



46
47
48
# File 'lib/ruby_llm/thinking.rb', line 46

def initialize(model)
  @model = model
end

Instance Method Details

#disableObject



67
68
69
70
71
72
73
74
# File 'lib/ruby_llm/thinking.rb', line 67

def disable
  return { effort: :none } if model.reasoning_option_values(:effort).include?('none')

  budget = model.reasoning_option(:budget_tokens)
  return { budget: 0 } if budget && budget[:min].is_a?(Numeric) && budget[:min] <= 0

  { enabled: false } if model.reasoning_option(:toggle) || budget
end

#enableObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ruby_llm/thinking.rb', line 50

def enable
  effort = default_effort
  return { effort: effort } if effort

  budget = explicit_budget
  return { budget: budget } if budget
  return { enabled: true } if model.reasoning_option(:toggle)

  effort = preferred_effort
  return { effort: effort } if effort

  budget = minimum_budget
  return { budget: budget } if budget

  :already_on if reasoning_model? && model.reasoning_options.empty?
end