Class: Llmemory::Cli::Commands::Search

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

Instance Method Summary collapse

Methods inherited from Base

#parse_options, #run

Instance Method Details

#execute(argv, _opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/llmemory/cli/commands/search.rb', line 14

def execute(argv, _opts)
  user_id = argv.shift
  query = argv.join(" ").strip
  unless user_id && !query.empty?
    $stderr.puts "Usage: llmemory search USER_ID \"query\" [--type short|long|all]"
    exit 1
  end

  type = @search_type || "all"

  if type == "short" || type == "all"
    search_short_term(user_id, query)
  end

  if type == "long" || type == "all"
    if Llmemory.configuration.long_term_type.to_s == "graph_based"
      search_graph_based(user_id, query)
    else
      search_file_based(user_id, query)
    end
  end
end

#option_parser(parser) ⇒ Object



9
10
11
12
# File 'lib/llmemory/cli/commands/search.rb', line 9

def option_parser(parser)
  parser.on("--type TYPE", "Search in: short, long, all (default: all)") { |v| @search_type = (v || "all").downcase }
  parser.on("--store TYPE", "Store type") { |v| @store_type = v }
end