Module: LiterLlm::ContentPart

Extended by:
T::Helpers, T::Sig
Included in:
ContentPartDocument, ContentPartImageUrl, ContentPartInputAudio, ContentPartText
Defined in:
lib/liter_llm/native.rb

Overview

A single content part in a user message — text, image, document, or audio.

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



260
261
262
263
264
265
266
267
268
269
# File 'lib/liter_llm/native.rb', line 260

def self.from_hash(hash)
  discriminator = hash[:type] || hash['type']
  case discriminator
  when 'text' then ContentPartText.from_hash(hash)
  when 'image_url' then ContentPartImageUrl.from_hash(hash)
  when 'document' then ContentPartDocument.from_hash(hash)
  when 'input_audio' then ContentPartInputAudio.from_hash(hash)
  else raise "Unknown discriminator: #{discriminator}"
  end
end