Module: OmniAI::Anthropic::Chat::MediaSerializer

Defined in:
lib/omniai/anthropic/chat/media_serializer.rb

Overview

Overrides media serialize / deserialize.

Class Method Summary collapse

Class Method Details

.serialize(media) ⇒ Hash

Parameters:

  • payload (OmniAI::Chat::Media)

Returns:

  • (Hash)


10
11
12
13
14
15
16
17
18
19
# File 'lib/omniai/anthropic/chat/media_serializer.rb', line 10

def self.serialize(media, *)
  {
    type: media.kind, # i.e. 'image' / 'video' / 'audio' / ...
    source: {
      type: 'base64',
      media_type: media.type, # i.e. 'image/jpeg' / 'video/ogg' / 'audio/mpeg' / ...
      data: media.data,
    },
  }
end