Class: AssistantStreamEvent

Inherits:
BaseStruct show all
Defined in:
lib/llm_gateway/adapters/structs.rb

Constant Summary collapse

EventType =
Types::Coercible::Symbol.enum(:text_start, :text_delta, :text_end, :tool_start, :tool_delta, :tool_end, :tool_result_start, :tool_result_delta, :tool_result_end, :reasoning_start, :reasoning_delta, :reasoning_end)

Instance Method Summary collapse

Instance Method Details

#contentObject



140
141
142
143
144
145
146
147
148
149
# File 'lib/llm_gateway/adapters/structs.rb', line 140

def content
  case type
  when :text_end
    finalized_content_block&.text
  when :reasoning_end
    finalized_content_block&.reasoning
  when :tool_end
    finalized_content_block
  end
end

#reasoningObject



155
156
157
# File 'lib/llm_gateway/adapters/structs.rb', line 155

def reasoning
  content if type == :reasoning_end
end

#textObject



151
152
153
# File 'lib/llm_gateway/adapters/structs.rb', line 151

def text
  content if type == :text_end
end

#tool_callObject Also known as: tool



159
160
161
# File 'lib/llm_gateway/adapters/structs.rb', line 159

def tool_call
  finalized_content_block if type == :tool_end
end