Module: OmniAI::Anthropic::Chat::ToolCallResultSerializer

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

Overview

Overrides tool-call response serialize / deserialize.

Class Method Summary collapse

Class Method Details

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

Parameters:

  • data (Hash)

Returns:

  • (OmniAI::Chat::ToolCallResult)


20
21
22
23
24
25
# File 'lib/omniai/anthropic/chat/tool_call_result_serializer.rb', line 20

def self.deserialize(data, *)
  tool_call_id = data['tool_use_id']
  content = data['content']

  OmniAI::Chat::ToolCallResult.new(content:, tool_call_id:)
end

.serialize(tool_call_result) ⇒ Hash

Parameters:

  • tool_call_result (OmniAI::Chat::ToolCallResult)

Returns:

  • (Hash)


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

def self.serialize(tool_call_result, *)
  {
    type: 'tool_result',
    tool_use_id: tool_call_result.tool_call_id,
    content: tool_call_result.content,
  }
end