Module: OmniAI::Anthropic::Chat::PayloadSerializer
- Defined in:
- lib/omniai/anthropic/chat/payload_serializer.rb
Overview
Overrides payload serialize / deserialize.
Class Method Summary collapse
Class Method Details
.deserialize(data, context:) ⇒ OmniAI::Chat::Payload
21 22 23 24 25 26 |
# File 'lib/omniai/anthropic/chat/payload_serializer.rb', line 21 def self.deserialize(data, context:) usage = OmniAI::Chat::Usage.deserialize(data['usage'], context:) if data['usage'] choice = OmniAI::Chat::Choice.deserialize(data, context:) OmniAI::Chat::Payload.new(choices: [choice], usage:) end |
.serialize(payload, context:) ⇒ Hash
11 12 13 14 15 16 |
# File 'lib/omniai/anthropic/chat/payload_serializer.rb', line 11 def self.serialize(payload, context:) usage = payload.usage.serialize(context:) choice = payload.choice.serialize(context:) choice.merge({ usage: }) end |