Class: AssistantStreamEvent

Inherits:
BaseStruct
  • Object
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, :reasoning_start, :reasoning_delta, :reasoning_end)

Instance Method Summary collapse

Instance Method Details

#contentObject



112
113
114
115
116
117
118
119
120
121
# File 'lib/llm_gateway/adapters/structs.rb', line 112

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



127
128
129
# File 'lib/llm_gateway/adapters/structs.rb', line 127

def reasoning
  content if type == :reasoning_end
end

#textObject



123
124
125
# File 'lib/llm_gateway/adapters/structs.rb', line 123

def text
  content if type == :text_end
end

#tool_callObject Also known as: tool



131
132
133
# File 'lib/llm_gateway/adapters/structs.rb', line 131

def tool_call
  finalized_content_block if type == :tool_end
end