Class: Legion::Extensions::Llm::Canonical::ThinkingConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/llm/canonical/thinking.rb

Overview

Normalized config for thinking across providers. Mirrors lex-llm Thinking::Config.

Constant Summary collapse

INCLUDES =
Thinking

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(effort: nil, budget: nil) ⇒ ThinkingConfig

Returns a new instance of ThinkingConfig.



55
56
57
58
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 55

def initialize(effort: nil, budget: nil)
  @effort = effort.is_a?(Symbol) ? effort.to_s : effort
  @budget = budget
end

Instance Attribute Details

#budgetObject (readonly)

Returns the value of attribute budget.



53
54
55
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 53

def budget
  @budget
end

#effortObject (readonly)

Returns the value of attribute effort.



53
54
55
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 53

def effort
  @effort
end

Class Method Details

.build(effort: nil, budget: nil) ⇒ Object

Build from keyword args.



61
62
63
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 61

def self.build(effort: nil, budget: nil)
  new(effort: effort, budget: budget)
end

.from_hash(source) ⇒ Object

Build from a Hash.



66
67
68
69
70
71
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 66

def self.from_hash(source)
  return nil if source.nil? || source.empty?

  h = source.transform_keys(&:to_sym)
  build(effort: h[:effort], budget: h[:budget])
end

Instance Method Details

#enabled?Boolean

Whether thinking is configured.

Returns:

  • (Boolean)


79
80
81
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 79

def enabled?
  !effort.nil? || !budget.nil?
end

#to_hObject

Serialize to a Hash for AMQP/fleet/wire transport.



74
75
76
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 74

def to_h
  { effort: effort, budget: budget }.compact
end