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.



46
47
48
49
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 46

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.



44
45
46
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 44

def budget
  @budget
end

#effortObject (readonly)

Returns the value of attribute effort.



44
45
46
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 44

def effort
  @effort
end

Class Method Details

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

Build from keyword args.



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

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

.from_hash(source) ⇒ Object

Build from a Hash.



57
58
59
60
61
62
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 57

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)


70
71
72
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 70

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

#to_hObject

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



65
66
67
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 65

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