Module: OmniAI::OpenAI::Chat::ResponseSerializer
- Defined in:
- lib/omniai/openai/chat/response_serializer.rb
Overview
Overrides response serialize / deserialize.
Class Method Summary collapse
Class Method Details
.deserialize(data, context:) ⇒ OmniAI::Chat::Response
26 27 28 29 30 31 |
# File 'lib/omniai/openai/chat/response_serializer.rb', line 26 def self.deserialize(data, context:) usage = OmniAI::Chat::Usage.deserialize(data["usage"], context:) if data["usage"] choices = data["output"].map { |choice_data| OmniAI::Chat::Choice.deserialize(choice_data, context:) } OmniAI::Chat::Response.new(data:, choices:, usage:) end |
.serialize(response, context:) ⇒ Hash
12 13 14 15 16 17 18 19 20 |
# File 'lib/omniai/openai/chat/response_serializer.rb', line 12 def self.serialize(response, context:) usage = response.usage.serialize(context:) output = response.choices.serialize(context:) { usage:, output:, } end |