Class: Riffer::StreamEvents::ToolCallDelta

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/stream_events/tool_call_delta.rb

Overview

Riffer::StreamEvents::ToolCallDelta represents an incremental tool call chunk during streaming.

Emitted when the LLM is building a tool call, containing partial argument data.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(item_id:, arguments_delta:, name: nil, role: :assistant) ⇒ ToolCallDelta

: (item_id: String, arguments_delta: String, ?name: String?, ?role: Symbol) -> void



18
19
20
21
22
23
# File 'lib/riffer/stream_events/tool_call_delta.rb', line 18

def initialize(item_id:, arguments_delta:, name: nil, role: :assistant)
  super(role: role)
  @item_id = item_id
  @name = name
  @arguments_delta = arguments_delta
end

Instance Attribute Details

#arguments_deltaObject (readonly)

The incremental arguments JSON fragment.



15
16
17
# File 'lib/riffer/stream_events/tool_call_delta.rb', line 15

def arguments_delta
  @arguments_delta
end

#item_idObject (readonly)

The tool call item identifier.



9
10
11
# File 'lib/riffer/stream_events/tool_call_delta.rb', line 9

def item_id
  @item_id
end

#nameObject (readonly)

The tool name (may only be present in first delta).



12
13
14
# File 'lib/riffer/stream_events/tool_call_delta.rb', line 12

def name
  @name
end

Instance Method Details

#to_hObject

: () -> Hash[Symbol, untyped]



26
27
28
# File 'lib/riffer/stream_events/tool_call_delta.rb', line 26

def to_h
  {role: @role, item_id: @item_id, name: @name, arguments_delta: @arguments_delta}.compact
end