Class: LangGraphRB::Observers::StepEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/langgraph_rb/observers/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, step_number:, active_nodes: [], completed_nodes: [], thread_id: nil, state: nil, duration: nil) ⇒ StepEvent



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/langgraph_rb/observers/base.rb', line 178

def initialize(type:, step_number:, active_nodes: [], completed_nodes: [], 
               thread_id: nil, state: nil, duration: nil)
  @type = type
  @step_number = step_number
  @active_nodes = active_nodes
  @completed_nodes = completed_nodes
  @thread_id = thread_id
  @state = state
  @duration = duration
  @timestamp = Time.now.utc
end

Instance Attribute Details

#active_nodesObject (readonly)

Returns the value of attribute active_nodes.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def active_nodes
  @active_nodes
end

#completed_nodesObject (readonly)

Returns the value of attribute completed_nodes.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def completed_nodes
  @completed_nodes
end

#durationObject (readonly)

Returns the value of attribute duration.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def duration
  @duration
end

#stateObject (readonly)

Returns the value of attribute state.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def state
  @state
end

#step_numberObject (readonly)

Returns the value of attribute step_number.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def step_number
  @step_number
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



175
176
177
# File 'lib/langgraph_rb/observers/base.rb', line 175

def type
  @type
end

Instance Method Details

#to_hObject



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/langgraph_rb/observers/base.rb', line 190

def to_h
  {
    type: @type,
    step_number: @step_number,
    active_nodes: @active_nodes,
    completed_nodes: @completed_nodes,
    thread_id: @thread_id,
    state: @state,
    duration_ms: @duration ? (@duration * 1000).round(2) : nil,
    timestamp: @timestamp.iso8601
  }
end