Class: LangGraphRB::Observers::NodeEvent

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:, node_name:, node_class: nil, state_before: nil, state_after: nil, context: nil, thread_id: nil, step_number: nil, duration: nil, error: nil, result: nil, from_node: nil) ⇒ NodeEvent

Returns a new instance of NodeEvent.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/langgraph_rb/observers/base.rb', line 136

def initialize(type:, node_name:, node_class: nil, state_before: nil, state_after: nil,
               context: nil, thread_id: nil, step_number: nil, duration: nil, 
               error: nil, result: nil, from_node: nil)
  @type = type
  @node_name = node_name
  @node_class = node_class
  @state_before = state_before
  @state_after = state_after
  @context = context
  @thread_id = thread_id
  @step_number = step_number
  @duration = duration
  @error = error
  @result = result
  @from_node = from_node
  @timestamp = Time.now.utc
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def context
  @context
end

#durationObject (readonly)

Returns the value of attribute duration.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def duration
  @duration
end

#errorObject (readonly)

Returns the value of attribute error.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def error
  @error
end

#from_nodeObject (readonly)

Returns the value of attribute from_node.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def from_node
  @from_node
end

#node_classObject (readonly)

Returns the value of attribute node_class.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def node_class
  @node_class
end

#node_nameObject (readonly)

Returns the value of attribute node_name.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def node_name
  @node_name
end

#resultObject (readonly)

Returns the value of attribute result.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def result
  @result
end

#state_afterObject (readonly)

Returns the value of attribute state_after.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def state_after
  @state_after
end

#state_beforeObject (readonly)

Returns the value of attribute state_before.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def state_before
  @state_before
end

#step_numberObject (readonly)

Returns the value of attribute step_number.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def step_number
  @step_number
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



133
134
135
# File 'lib/langgraph_rb/observers/base.rb', line 133

def type
  @type
end

Instance Method Details

#to_hObject



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/langgraph_rb/observers/base.rb', line 154

def to_h
  {
    type: @type,
    node_name: @node_name,
    node_class: @node_class&.name,
    from_node: @from_node,
    state_before: @state_before,
    state_after: @state_after,
    context: @context,
    thread_id: @thread_id,
    step_number: @step_number,
    duration_ms: @duration ? (@duration * 1000).round(2) : nil,
    error: @error&.message,
    error_class: @error&.class&.name,
    result_type: @result&.class&.name,
    timestamp: @timestamp.iso8601
  }
end