Class: Kreator::ToolCall

Inherits:
Object
  • Object
show all
Defined in:
lib/kreator/tool_call.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ToolCall.



7
8
9
10
11
12
13
# File 'lib/kreator/tool_call.rb', line 7

def initialize(id:, name:, arguments: {}, raw_arguments: nil, metadata: {})
  @id = id.to_s
  @name = name.to_s
  @arguments = arguments || {}
  @raw_arguments = raw_arguments
  @metadata =  || {}
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



5
6
7
# File 'lib/kreator/tool_call.rb', line 5

def arguments
  @arguments
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/kreator/tool_call.rb', line 5

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/kreator/tool_call.rb', line 5

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/kreator/tool_call.rb', line 5

def name
  @name
end

#raw_argumentsObject (readonly)

Returns the value of attribute raw_arguments.



5
6
7
# File 'lib/kreator/tool_call.rb', line 5

def raw_arguments
  @raw_arguments
end

Class Method Details

.from_h(hash) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/kreator/tool_call.rb', line 15

def self.from_h(hash)
  new(
    id: hash.fetch("id", hash[:id]),
    name: hash.fetch("name", hash[:name]),
    arguments: hash.fetch("arguments", hash[:arguments] || {}),
    raw_arguments: hash.fetch("raw_arguments", hash[:raw_arguments] || nil),
    metadata: hash.fetch("metadata", hash[:metadata] || {})
  )
end

Instance Method Details

#to_hObject



25
26
27
28
29
30
31
32
33
# File 'lib/kreator/tool_call.rb', line 25

def to_h
  {
    "id" => id,
    "name" => name,
    "arguments" => arguments,
    "raw_arguments" => raw_arguments,
    "metadata" => 
  }.compact
end