Class: CircuitBreaker::Executors::LLM::ConversationMemory

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, #to_h

Constructor Details

#initialize(system_prompt: nil) ⇒ ConversationMemory

Returns a new instance of ConversationMemory.



42
43
44
45
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 42

def initialize(system_prompt: nil)
  super()
  add_message(role: 'system', content: system_prompt) if system_prompt
end

Instance Method Details

#add_assistant_message(content, metadata: {}) ⇒ Object



51
52
53
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 51

def add_assistant_message(content, metadata: {})
  add_message(role: 'assistant', content: content, metadata: )
end

#add_user_message(content, metadata: {}) ⇒ Object



47
48
49
# File 'lib/circuit_breaker/executors/llm/memory.rb', line 47

def add_user_message(content, metadata: {})
  add_message(role: 'user', content: content, metadata: )
end