Class: Llmemory::ShortTerm::Checkpoint
- Inherits:
-
Object
- Object
- Llmemory::ShortTerm::Checkpoint
- Defined in:
- lib/llmemory/short_term/checkpoint.rb
Constant Summary collapse
- DEFAULT_SESSION_ID =
"default"
Instance Method Summary collapse
- #clear_state ⇒ Object
-
#initialize(user_id:, session_id: DEFAULT_SESSION_ID, store: nil) ⇒ Checkpoint
constructor
A new instance of Checkpoint.
- #restore_state ⇒ Object
- #save_state(state) ⇒ Object
Constructor Details
#initialize(user_id:, session_id: DEFAULT_SESSION_ID, store: nil) ⇒ Checkpoint
Returns a new instance of Checkpoint.
13 14 15 16 17 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 13 def initialize(user_id:, session_id: DEFAULT_SESSION_ID, store: nil) @user_id = user_id @session_id = session_id @store = store || build_store end |
Instance Method Details
#clear_state ⇒ Object
27 28 29 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 27 def clear_state @store.delete(@user_id, @session_id) end |
#restore_state ⇒ Object
23 24 25 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 23 def restore_state @store.load(@user_id, @session_id) end |
#save_state(state) ⇒ Object
19 20 21 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 19 def save_state(state) @store.save(@user_id, @session_id, state) end |