Module: OmniAI::Google::Chat::ToolCallResultSerializer

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

Overview

Overrides tool-call result serialize / deserialize.

Class Method Summary collapse

Class Method Details

.deserialize(data) ⇒ ToolCallResult

Parameters:

  • data (Hash)

Returns:

  • (ToolCallResult)


24
25
26
27
28
# File 'lib/omniai/google/chat/tool_call_result_serializer.rb', line 24

def self.deserialize(data, *)
  tool_call_id = data['functionResponse']['name']
  content = data['functionResponse']['response']['content']
  OmniAI::Chat::ToolCallResult.new(content:, tool_call_id:)
end

.serialize(tool_call_response) ⇒ Hash

Parameters:

  • tool_call_response (OmniAI::Chat::ToolCallResult)

Returns:

  • (Hash)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/omniai/google/chat/tool_call_result_serializer.rb', line 10

def self.serialize(tool_call_response, *)
  {
    functionResponse: {
      name: tool_call_response.tool_call_id,
      response: {
        name: tool_call_response.tool_call_id,
        content: tool_call_response.content,
      },
    },
  }
end