Class: Llmemory::Cli::Commands::Working

Inherits:
Base
  • Object
show all
Defined in:
lib/llmemory/cli/commands/working.rb

Instance Method Summary collapse

Methods inherited from Base

#option_parser, #parse_options, #run

Instance Method Details

#execute(argv, _opts) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/llmemory/cli/commands/working.rb', line 9

def execute(argv, _opts)
  user_id, session_id = argv
  unless user_id && session_id
    $stderr.puts "Usage: llmemory working USER_ID SESSION_ID"
    exit 1
  end

  wm = Llmemory::WorkingMemory.new(user_id: user_id, session_id: session_id, store: short_term_store)
  state = wm.to_h

  if state.empty?
    puts "Empty working memory for user #{user_id}, session #{session_id}."
    return
  end

  state.each do |slot, value|
    puts "#{slot}: #{value.inspect}"
  end
end