Class: LangGraphRB::Observers::GraphEvent

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

Overview

Event data structures

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, graph:, initial_state: nil, context: nil, thread_id: nil) ⇒ GraphEvent

Returns a new instance of GraphEvent.



95
96
97
98
99
100
101
102
# File 'lib/langgraph_rb/observers/base.rb', line 95

def initialize(type:, graph:, initial_state: nil, context: nil, thread_id: nil)
  @type = type
  @graph = graph
  @initial_state = initial_state
  @context = context
  @thread_id = thread_id
  @timestamp = Time.now.utc
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def context
  @context
end

#graphObject (readonly)

Returns the value of attribute graph.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def graph
  @graph
end

#initial_stateObject (readonly)

Returns the value of attribute initial_state.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def initial_state
  @initial_state
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def thread_id
  @thread_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



93
94
95
# File 'lib/langgraph_rb/observers/base.rb', line 93

def type
  @type
end

Instance Method Details

#to_hObject



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/langgraph_rb/observers/base.rb', line 104

def to_h
  {
    type: @type,
    graph_class: @graph.class.name,
    node_count: @graph.nodes.size,
    edge_count: @graph.edges.size,
    initial_state: @initial_state,
    context: @context,
    thread_id: @thread_id,
    timestamp: @timestamp.iso8601
  }
end