Module: OmniAI::Google::Chat::ChoiceSerializer

Defined in:
lib/omniai/google/chat/choice_serializer.rb

Overview

Overrides choice serialize / deserialize.

Class Method Summary collapse

Class Method Details

.deserialize(data, context:) ⇒ OmniAI::Chat::Choice

Parameters:

  • data (Hash)
  • context (Context)

Returns:

  • (OmniAI::Chat::Choice)


19
20
21
22
# File 'lib/omniai/google/chat/choice_serializer.rb', line 19

def self.deserialize(data, context:)
  message = OmniAI::Chat::Message.deserialize(data['content'], context:)
  OmniAI::Chat::Choice.new(message:)
end

.serialize(choice, context:) ⇒ Hash

Parameters:

  • choice (OmniAI::Chat::Choice)
  • context (Context)

Returns:

  • (Hash)


11
12
13
14
# File 'lib/omniai/google/chat/choice_serializer.rb', line 11

def self.serialize(choice, context:)
  content = choice.message.serialize(context:)
  { content: }
end