Class: Protege::Inference::Provider::ToolCall
- Inherits:
-
Data
- Object
- Data
- Protege::Inference::Provider::ToolCall
- Defined in:
- lib/protege/inference/provider/tool_call.rb
Overview
One tool call emitted by the model in a Response (Protege's internal representation).
id: provider-assigned identifier used to correlate the eventual tool-result message back to
this call.
name: snake_case tool name to invoke.
input: parsed input hash matching the tool's input schema.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.from_wire(hash) ⇒ ToolCall
Build a ToolCall from a function-call wire hash:
{ id:, type: "function", function: { name:, arguments: <JSON string> } }— the shape the model emits in the response hash. -
.parse_arguments(raw) ⇒ Hash
Decode the JSON
argumentsstring into an input hash (empty when blank).
Instance Method Summary collapse
-
#to_wire ⇒ Hash
Render this call in the standard function-call wire shape, with JSON-encoded arguments — the same serialization a request's assistant turn and a trace's response snapshot both use.
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id
14 15 16 |
# File 'lib/protege/inference/provider/tool_call.rb', line 14 def id @id end |
#input ⇒ Object (readonly)
Returns the value of attribute input
14 15 16 |
# File 'lib/protege/inference/provider/tool_call.rb', line 14 def input @input end |
#name ⇒ Object (readonly)
Returns the value of attribute name
14 15 16 |
# File 'lib/protege/inference/provider/tool_call.rb', line 14 def name @name end |
Class Method Details
.from_wire(hash) ⇒ ToolCall
Build a ToolCall from a function-call wire hash:
{ id:, type: "function", function: { name:, arguments: <JSON string> } } — the shape the
model emits in the response hash. arguments is JSON-decoded into input.
25 26 27 28 |
# File 'lib/protege/inference/provider/tool_call.rb', line 25 def self.from_wire(hash) function = hash[:function] || {} new(id: hash[:id], name: function[:name], input: parse_arguments(function[:arguments])) end |
.parse_arguments(raw) ⇒ Hash
Decode the JSON arguments string into an input hash (empty when blank).
34 35 36 |
# File 'lib/protege/inference/provider/tool_call.rb', line 34 def self.parse_arguments(raw) raw.present? ? JSON.parse(raw) : {} end |
Instance Method Details
#to_wire ⇒ Hash
Render this call in the standard function-call wire shape, with JSON-encoded arguments — the same serialization a request's assistant turn and a trace's response snapshot both use.
42 43 44 45 46 47 48 |
# File 'lib/protege/inference/provider/tool_call.rb', line 42 def to_wire { id:, type: 'function', function: { name:, arguments: input.to_json } } end |