Class: Legion::Extensions::Llm::ToolCall

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

Overview

Represents a function call from an AI model to a Tool.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

index carries the provider's authoritative wire position (delta.tool_calls.index) so the StreamAccumulator can correlate interleaved argument fragments to the right parallel call by index rather than by recency. nil for non-streaming/single-call paths.



15
16
17
18
19
20
21
# File 'lib/legion/extensions/llm/tool_call.rb', line 15

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

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#indexObject (readonly)

Returns the value of attribute index.



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

def index
  @index
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#thought_signatureObject

Returns the value of attribute thought_signature.



9
10
11
# File 'lib/legion/extensions/llm/tool_call.rb', line 9

def thought_signature
  @thought_signature
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
# File 'lib/legion/extensions/llm/tool_call.rb', line 23

def to_h
  {
    id: @id,
    name: @name,
    arguments: @arguments,
    thought_signature: @thought_signature
  }.compact
end