Class: Riffer::StreamEvents::Base

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

Overview

Base class for all streaming events in the Riffer framework.

Subclasses must implement the to_h method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role: :assistant) ⇒ Base

Creates a new stream event.

role

Symbol - the message role (defaults to :assistant)



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

def initialize(role: :assistant)
  @role = role
end

Instance Attribute Details

#roleObject (readonly)

The message role (typically :assistant).

Returns Symbol.



10
11
12
# File 'lib/riffer/stream_events/base.rb', line 10

def role
  @role
end

Instance Method Details

#to_hObject

Converts the event to a hash.

Raises NotImplementedError if not implemented by subclass.

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/riffer/stream_events/base.rb', line 22

def to_h
  raise NotImplementedError, "Subclasses must implement #to_h"
end