Class: OmniAI::Chat::ToolCallResult
- Inherits:
-
Object
- Object
- OmniAI::Chat::ToolCallResult
- Defined in:
- lib/omniai/chat/tool_call_result.rb
Overview
The result of a tool call.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content:, tool_call_id:) ⇒ ToolCallResult
constructor
A new instance of ToolCallResult.
- #inspect ⇒ String
- #serialize(context: nil) ⇒ Hash
Constructor Details
#initialize(content:, tool_call_id:) ⇒ ToolCallResult
Returns a new instance of ToolCallResult.
15 16 17 18 |
# File 'lib/omniai/chat/tool_call_result.rb', line 15 def initialize(content:, tool_call_id:) @content = content @tool_call_id = tool_call_id end |
Instance Attribute Details
#content ⇒ Object
8 9 10 |
# File 'lib/omniai/chat/tool_call_result.rb', line 8 def content @content end |
#tool_call_id ⇒ ToolCall
11 12 13 |
# File 'lib/omniai/chat/tool_call_result.rb', line 11 def tool_call_id @tool_call_id end |
Class Method Details
.deserialize(data, context: nil) ⇒ ToolCallResult
40 41 42 43 44 45 46 47 48 |
# File 'lib/omniai/chat/tool_call_result.rb', line 40 def self.deserialize(data, context: nil) deserialize = context&.deserializer(:tool_call_result) return deserialize.call(data, context:) if deserialize content = JSON.parse(data['content']) tool_call_id = data['tool_call_id'] new(content:, tool_call_id:) end |
Instance Method Details
#inspect ⇒ String
21 22 23 |
# File 'lib/omniai/chat/tool_call_result.rb', line 21 def inspect "#<#{self.class.name} content=#{content.inspect} tool_call_id=#{tool_call_id.inspect}>" end |
#serialize(context: nil) ⇒ Hash
27 28 29 30 31 32 33 34 35 |
# File 'lib/omniai/chat/tool_call_result.rb', line 27 def serialize(context: nil) serializer = context&.serializer(:tool_call_result) return serializer.call(self, context:) if serializer content = JSON.generate(@content) tool_call_id = @tool_call_id { content:, tool_call_id: } end |