Class: ActiveAgent::Memory::InMemory
- Inherits:
-
Base
- Object
- Base
- ActiveAgent::Memory::InMemory
show all
- Defined in:
- lib/active_agent/memory/in_memory.rb
Class Attribute Summary collapse
Attributes inherited from Base
#conversation_id
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Attribute Details
.store ⇒ Object
Returns the value of attribute store.
11
12
13
|
# File 'lib/active_agent/memory/in_memory.rb', line 11
def store
@store
end
|
Instance Method Details
#add_message(role:, content:, **options) ⇒ Object
18
19
20
21
22
|
# File 'lib/active_agent/memory/in_memory.rb', line 18
def add_message(role:, content:, **options)
message = { role: role, content: content }.merge(options)
self.class.store[conversation_id] << message
message
end
|
#clear ⇒ Object
24
25
26
|
# File 'lib/active_agent/memory/in_memory.rb', line 24
def clear
self.class.store[conversation_id] = []
end
|
#messages ⇒ Object
14
15
16
|
# File 'lib/active_agent/memory/in_memory.rb', line 14
def messages
self.class.store[conversation_id]
end
|