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



28
29
30
31
32
# File 'lib/omniai/google/chat/tool_call_result_serializer.rb', line 28

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



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

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

  thought_signature = tool_call_response.options[:thought_signature]
  result[:thoughtSignature] = thought_signature if thought_signature
  result
end