Module: OmniAI::Anthropic::Chat::FunctionSerializer

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

Overview

Overrides function serialize / deserialize.

Class Method Summary collapse

Class Method Details

.deserialize(data) ⇒ OmniAI::Chat::Function

Parameters:

  • data (Hash)

Returns:

  • (OmniAI::Chat::Function)


19
20
21
22
23
# File 'lib/omniai/anthropic/chat/function_serializer.rb', line 19

def self.deserialize(data, *)
  name = data['name']
  arguments = data['input']
  OmniAI::Chat::Function.new(name:, arguments:)
end

.serialize(function) ⇒ Hash

Parameters:

  • function (OmniAI::Chat::Function)

Returns:

  • (Hash)


10
11
12
13
14
15
# File 'lib/omniai/anthropic/chat/function_serializer.rb', line 10

def self.serialize(function, *)
  {
    name: function.name,
    input: function.arguments,
  }
end