Class: CircuitBreaker::Executors::LLM::ChainMemory

Inherits:
Memory
  • Object
show all
Defined in:
lib/circuit_breaker/executors/llm/memory.rb

Instance Attribute Summary

Attributes inherited from Memory

#messages, #metadata

Instance Method Summary collapse

Methods inherited from Memory

#add_message, #clear, #get_context

Constructor Details

#initializeChainMemory



57
58
59
60
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 57

def initialize
  super
  @intermediate_steps = []
end

Instance Method Details

#add_step_result(step_name:, input:, output:, metadata: {}) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 62

def add_step_result(step_name:, input:, output:, metadata: {})
  @intermediate_steps << {
    step_name: step_name,
    input: input,
    output: output,
    timestamp: Time.now.utc,
    metadata: 
  }
end

#get_step_historyObject



72
73
74
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 72

def get_step_history
  @intermediate_steps
end

#to_hObject



76
77
78
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 76

def to_h
  super.merge(intermediate_steps: @intermediate_steps)
end