Module: Intelligence::MessageContent

Defined in:
lib/intelligence/message_content.rb,
lib/intelligence/message_content/base.rb,
lib/intelligence/message_content/file.rb,
lib/intelligence/message_content/text.rb,
lib/intelligence/message_content/binary.rb,
lib/intelligence/message_content/tool_call.rb,
lib/intelligence/message_content/tool_result.rb

Defined Under Namespace

Classes: Base, Binary, File, Text, ToolCall, ToolResult

Class Method Summary collapse

Class Method Details

.[](type) ⇒ Object

Raises:

  • (TypeError)


8
9
10
11
12
13
# File 'lib/intelligence/message_content.rb', line 8

def self.[]( type ) 
  type_name = type.to_s.split( '_' ).map { | word | word.capitalize }.join
  klass = Intelligence.const_get( "MessageContent::#{type_name}" ) rescue nil
  raise TypeError, "An unknown content type '#{type}' was given." unless klass
  klass
end

.build(type, attributes = nil, &block) ⇒ Object



19
20
21
# File 'lib/intelligence/message_content.rb', line 19

def self.build( type, attributes = nil, &block )
  self[ type ].build( attributes, &block )
end

.build!(type, attributes = nil, &block) ⇒ Object



15
16
17
# File 'lib/intelligence/message_content.rb', line 15

def self.build!( type, attributes = nil, &block )
  self[ type ].build!( attributes, &block )
end