Class: LittleGhost::Content::ToolUse

Inherits:
Data
  • Object
show all
Includes:
Module.new do # :nodoc: def to_h = Content.serialize(self) def to_json(*arguments) = JSON.generate(to_h, *arguments) end
Defined in:
lib/little_ghost/content.rb,
lib/little_ghost/content.rb

Overview

Describes one tool call requested by a provider-backed model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, input:) ⇒ ToolUse

Returns a new instance of ToolUse.



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/little_ghost/content.rb', line 33

def initialize(id:, name:, input:)
  id = String(id)
  name = String(name)
  raise ArgumentError, "tool use id is required" if id.empty?
  raise ArgumentError, "tool use name is required" if name.empty?
  raise ArgumentError, "tool use input must be an object" unless input.is_a?(Hash)

  super(id: id.to_s, name: name.to_s, input:)
rescue TypeError
  raise ArgumentError, "tool use id and name must be strings"
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



30
31
32
# File 'lib/little_ghost/content.rb', line 30

def id
  @id
end

#inputObject (readonly)

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



30
31
32
# File 'lib/little_ghost/content.rb', line 30

def input
  @input
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



30
31
32
# File 'lib/little_ghost/content.rb', line 30

def name
  @name
end