Class: Legion::LLM::Types::ContentBlock
- Inherits:
-
Data
- Object
- Data
- Legion::LLM::Types::ContentBlock
- Defined in:
- lib/legion/llm/types/content_block.rb
Instance Attribute Summary collapse
-
#cache_control ⇒ Object
readonly
Returns the value of attribute cache_control.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#end_index ⇒ Object
readonly
Returns the value of attribute end_index.
-
#file_id ⇒ Object
readonly
Returns the value of attribute file_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#is_error ⇒ Object
readonly
Returns the value of attribute is_error.
-
#media_type ⇒ Object
readonly
Returns the value of attribute media_type.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_type ⇒ Object
readonly
Returns the value of attribute source_type.
-
#start_index ⇒ Object
readonly
Returns the value of attribute start_index.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tool_use_id ⇒ Object
readonly
Returns the value of attribute tool_use_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .build_with(**overrides) ⇒ Object
- .from_hash(hash) ⇒ Object
- .image(data:, media_type:, source_type: :base64, detail: nil) ⇒ Object
- .text(content, cache_control: nil) ⇒ Object
- .thinking(content) ⇒ Object
- .tool_result(tool_use_id:, content:, is_error: false) ⇒ Object
- .tool_use(id:, name:, input:) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#cache_control ⇒ Object (readonly)
Returns the value of attribute cache_control
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def cache_control @cache_control end |
#code ⇒ Object (readonly)
Returns the value of attribute code
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def data @data end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def detail @detail end |
#end_index ⇒ Object (readonly)
Returns the value of attribute end_index
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def end_index @end_index end |
#file_id ⇒ Object (readonly)
Returns the value of attribute file_id
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def file_id @file_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def id @id end |
#input ⇒ Object (readonly)
Returns the value of attribute input
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def input @input end |
#is_error ⇒ Object (readonly)
Returns the value of attribute is_error
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def is_error @is_error end |
#media_type ⇒ Object (readonly)
Returns the value of attribute media_type
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def media_type @media_type end |
#message ⇒ Object (readonly)
Returns the value of attribute message
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def source @source end |
#source_type ⇒ Object (readonly)
Returns the value of attribute source_type
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def source_type @source_type end |
#start_index ⇒ Object (readonly)
Returns the value of attribute start_index
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def start_index @start_index end |
#text ⇒ Object (readonly)
Returns the value of attribute text
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def text @text end |
#tool_use_id ⇒ Object (readonly)
Returns the value of attribute tool_use_id
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def tool_use_id @tool_use_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type
6 7 8 |
# File 'lib/legion/llm/types/content_block.rb', line 6 def type @type end |
Class Method Details
.build_with(**overrides) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/legion/llm/types/content_block.rb', line 39 def self.build_with(**overrides) defaults = { type: nil, text: nil, data: nil, source_type: nil, media_type: nil, detail: nil, name: nil, file_id: nil, id: nil, input: nil, tool_use_id: nil, is_error: nil, source: nil, start_index: nil, end_index: nil, code: nil, message: nil, cache_control: nil } new(**defaults, **overrides) end |
.from_hash(hash) ⇒ Object
34 35 36 37 |
# File 'lib/legion/llm/types/content_block.rb', line 34 def self.from_hash(hash) hash = hash.transform_keys(&:to_sym) if hash.respond_to?(:transform_keys) build_with(**hash) end |
.image(data:, media_type:, source_type: :base64, detail: nil) ⇒ Object
29 30 31 32 |
# File 'lib/legion/llm/types/content_block.rb', line 29 def self.image(data:, media_type:, source_type: :base64, detail: nil) build_with(type: :image, data: data, media_type: media_type, source_type: source_type, detail: detail) end |
.text(content, cache_control: nil) ⇒ Object
13 14 15 |
# File 'lib/legion/llm/types/content_block.rb', line 13 def self.text(content, cache_control: nil) build_with(type: :text, text: content, cache_control: cache_control) end |
.thinking(content) ⇒ Object
17 18 19 |
# File 'lib/legion/llm/types/content_block.rb', line 17 def self.thinking(content) build_with(type: :thinking, text: content) end |
.tool_result(tool_use_id:, content:, is_error: false) ⇒ Object
25 26 27 |
# File 'lib/legion/llm/types/content_block.rb', line 25 def self.tool_result(tool_use_id:, content:, is_error: false) build_with(type: :tool_result, tool_use_id: tool_use_id, text: content, is_error: is_error) end |
.tool_use(id:, name:, input:) ⇒ Object
21 22 23 |
# File 'lib/legion/llm/types/content_block.rb', line 21 def self.tool_use(id:, name:, input:) build_with(type: :tool_use, id: id, name: name, input: input) end |
Instance Method Details
#to_h ⇒ Object
49 50 51 |
# File 'lib/legion/llm/types/content_block.rb', line 49 def to_h super.compact end |