Class: RubyLLM::Thinking

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

Overview

Represents provider thinking output.

Defined Under Namespace

Classes: Config

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text: nil, signature: nil) ⇒ Thinking

Returns a new instance of Thinking.



8
9
10
11
# File 'lib/ruby_llm/thinking.rb', line 8

def initialize(text: nil, signature: nil)
  @text = text
  @signature = signature
end

Instance Attribute Details

#signatureObject (readonly)

Returns the value of attribute signature.



6
7
8
# File 'lib/ruby_llm/thinking.rb', line 6

def signature
  @signature
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/ruby_llm/thinking.rb', line 6

def text
  @text
end

Class Method Details

.build(text: nil, signature: nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/ruby_llm/thinking.rb', line 13

def self.build(text: nil, signature: nil)
  text = nil if text.is_a?(String) && text.empty?
  signature = nil if signature.is_a?(String) && signature.empty?

  return nil if text.nil? && signature.nil?

  new(text: text, signature: signature)
end

Instance Method Details

#pretty_print(printer) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby_llm/thinking.rb', line 22

def pretty_print(printer)
  printer.object_group(self) do
    printer.breakable
    printer.text 'text='
    printer.pp text
    printer.comma_breakable
    printer.text 'signature='
    printer.pp(signature ? '[REDACTED]' : nil)
  end
end