Class: Legion::Extensions::Llm::Canonical::Thinking
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Canonical::Thinking
- Defined in:
- lib/legion/extensions/llm/canonical/thinking.rb
Overview
Canonical thinking/reasoning block. Ports field vocabulary from Legion::LLM::Types and lex-llm Thinking.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Class Method Summary collapse
-
.from_hash(source) ⇒ Object
Build from a Hash (raw provider response or deserialized wire payload).
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether this thinking block has any content.
-
#to_h ⇒ Object
Serialize to a Hash for AMQP/fleet/wire transport.
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
11 12 13 |
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 11 def content @content end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature
11 12 13 |
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 11 def signature @signature end |
Class Method Details
.from_hash(source) ⇒ Object
Build from a Hash (raw provider response or deserialized wire payload).
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 13 def self.from_hash(source) return nil if source.nil? h = source.transform_keys(&:to_sym) # Treat empty strings as nil content = h[:content] content = nil if content.is_a?(String) && content.empty? signature = h[:signature] signature = nil if signature.is_a?(String) && signature.empty? return nil if content.nil? && signature.nil? new(content: content, signature: signature) end |
Instance Method Details
#empty? ⇒ Boolean
Whether this thinking block has any content.
35 36 37 |
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 35 def empty? content.nil? && signature.nil? end |
#to_h ⇒ Object
Serialize to a Hash for AMQP/fleet/wire transport.
30 31 32 |
# File 'lib/legion/extensions/llm/canonical/thinking.rb', line 30 def to_h super.compact end |