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

Returns a new instance of StepEvent.



162
163
164
165
166
167
168
169
170
171
172
# File 'lib/langgraph_rb/observers/base.rb', line 162

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.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def active_nodes
  @active_nodes
end

#completed_nodesObject (readonly)

Returns the value of attribute completed_nodes.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def completed_nodes
  @completed_nodes
end

#durationObject (readonly)

Returns the value of attribute duration.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def duration
  @duration
end

#stateObject (readonly)

Returns the value of attribute state.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def state
  @state
end

#step_numberObject (readonly)

Returns the value of attribute step_number.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def step_number
  @step_number
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



159
160
161
# File 'lib/langgraph_rb/observers/base.rb', line 159

def type
  @type
end

Instance Method Details

#to_hObject



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/langgraph_rb/observers/base.rb', line 174

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