Class: Crimson::Message::ToolCall

Inherits:
Object
  • Object
show all
Defined in:
lib/crimson/message.rb

Overview

Represents a tool/function call requested by the model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, arguments: {}) ⇒ ToolCall

Returns a new instance of ToolCall.

Parameters:

  • id (String)
  • name (String)
  • arguments (Hash) (defaults to: {})


117
118
119
120
121
# File 'lib/crimson/message.rb', line 117

def initialize(id:, name:, arguments: {})
  @id = id
  @name = name
  @arguments = arguments
end

Instance Attribute Details

#argumentsString, Hash (readonly)

Returns:

  • (String)

    unique identifier for this tool call

  • (String)

    name of the tool

  • (Hash)

    arguments passed to the tool



112
113
114
# File 'lib/crimson/message.rb', line 112

def arguments
  @arguments
end

#idString, Hash (readonly)

Returns:

  • (String)

    unique identifier for this tool call

  • (String)

    name of the tool

  • (Hash)

    arguments passed to the tool



112
113
114
# File 'lib/crimson/message.rb', line 112

def id
  @id
end

#nameString, Hash (readonly)

Returns:

  • (String)

    unique identifier for this tool call

  • (String)

    name of the tool

  • (Hash)

    arguments passed to the tool



112
113
114
# File 'lib/crimson/message.rb', line 112

def name
  @name
end

Instance Method Details

#to_openai_hHash

Returns OpenAI-compatible tool call representation.

Returns:

  • (Hash)

    OpenAI-compatible tool call representation



124
125
126
127
128
129
130
131
132
133
# File 'lib/crimson/message.rb', line 124

def to_openai_h
  {
    id: @id,
    type: "function",
    function: {
      name: @name,
      arguments: JSON.generate(@arguments)
    }
  }
end