Class: Legion::CLI::Chat::Tools::SaveMemory

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/legion/cli/chat/tools/save_memory.rb

Constant Summary collapse

DEFAULT_PORT =
4567
DEFAULT_HOST =
'127.0.0.1'

Instance Method Summary collapse

Instance Method Details

#execute(text:, scope: 'project') ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/cli/chat/tools/save_memory.rb', line 21

def execute(text:, scope: 'project')
  require 'legion/cli/chat/memory_store'
  sym_scope = scope.to_s == 'global' ? :global : :project
  path = MemoryStore.add(text, scope: sym_scope)
  apollo_status = ingest_to_apollo(text, sym_scope)

  parts = ["Saved to #{sym_scope} memory (#{path})"]
  parts << apollo_status if apollo_status
  parts.join("\n")
rescue StandardError => e
  Legion::Logging.warn("SaveMemory#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error saving memory: #{e.message}"
end