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.
10 11 12 13 14 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 10 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
24 25 26 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 24 def clear_state @store.delete(@user_id, @session_id) end |
#restore_state ⇒ Object
20 21 22 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 20 def restore_state @store.load(@user_id, @session_id) end |
#save_state(state) ⇒ Object
16 17 18 |
# File 'lib/llmemory/short_term/checkpoint.rb', line 16 def save_state(state) @store.save(@user_id, @session_id, state) end |