Class: Legion::LLM::Pipeline::Timeline

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/llm/pipeline/timeline.rb

Instance Method Summary collapse

Constructor Details

#initializeTimeline

Returns a new instance of Timeline.



7
8
9
10
11
# File 'lib/legion/llm/pipeline/timeline.rb', line 7

def initialize
  @events = []
  @seq = 0
  @participant_set = []
end

Instance Method Details

#eventsObject



33
34
35
# File 'lib/legion/llm/pipeline/timeline.rb', line 33

def events
  @events.dup.freeze
end

#participantsObject



37
38
39
# File 'lib/legion/llm/pipeline/timeline.rb', line 37

def participants
  @participant_set.dup.freeze
end

#record(category:, key:, detail:, exchange_id: nil, direction: nil, from: nil, to: nil, duration_ms: nil, data: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/legion/llm/pipeline/timeline.rb', line 13

def record(category:, key:, detail:, exchange_id: nil, direction: nil,
           from: nil, to: nil, duration_ms: nil, data: nil)
  @seq += 1
  @events << {
    seq:         @seq,
    exchange_id: exchange_id,
    timestamp:   Time.now,
    category:    category,
    key:         key,
    direction:   direction,
    from:        from,
    to:          to,
    detail:      detail,
    duration_ms: duration_ms,
    data:        data
  }
  track_participant(from)
  track_participant(to)
end