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) ⇒ NodeEvent

Returns a new instance of NodeEvent.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/langgraph_rb/observers/base.rb', line 122

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)
  @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
  @timestamp = Time.now.utc
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def context
  @context
end

#durationObject (readonly)

Returns the value of attribute duration.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def duration
  @duration
end

#errorObject (readonly)

Returns the value of attribute error.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def error
  @error
end

#node_classObject (readonly)

Returns the value of attribute node_class.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def node_class
  @node_class
end

#node_nameObject (readonly)

Returns the value of attribute node_name.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def node_name
  @node_name
end

#resultObject (readonly)

Returns the value of attribute result.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def result
  @result
end

#state_afterObject (readonly)

Returns the value of attribute state_after.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def state_after
  @state_after
end

#state_beforeObject (readonly)

Returns the value of attribute state_before.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def state_before
  @state_before
end

#step_numberObject (readonly)

Returns the value of attribute step_number.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def step_number
  @step_number
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



119
120
121
# File 'lib/langgraph_rb/observers/base.rb', line 119

def type
  @type
end

Instance Method Details

#to_hObject



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

def to_h
  {
    type: @type,
    node_name: @node_name,
    node_class: @node_class&.name,
    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