Module: OmniAI::Anthropic::Chat::ChoiceSerializer

Defined in:
lib/omniai/anthropic/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)


18
19
20
21
# File 'lib/omniai/anthropic/chat/choice_serializer.rb', line 18

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

.serialize(choice, context:) ⇒ Hash

Parameters:

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

Returns:

  • (Hash)


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

def self.serialize(choice, context:)
  choice.message.serialize(context:)
end