Class: Rixie::LLM::ToolCall

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ToolCall.



10
11
12
13
14
# File 'lib/rixie/llm/tool_call.rb', line 10

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

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



8
9
10
# File 'lib/rixie/llm/tool_call.rb', line 8

def arguments
  @arguments
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/rixie/llm/tool_call.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/rixie/llm/tool_call.rb', line 8

def name
  @name
end

Class Method Details

.from_openai_wire(raw) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rixie/llm/tool_call.rb', line 16

def self.from_openai_wire(raw)
  new(
    id: raw["id"],
    name: raw["function"]["name"],
    arguments: JSON.parse(raw["function"]["arguments"])
  )
end

Instance Method Details

#to_openai_wireObject



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

def to_openai_wire
  {
    "id" => @id,
    "type" => "function",
    "function" => {
      "name" => @name,
      "arguments" => JSON.generate(@arguments)
    }
  }
end