Class: Zephira::Commands::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/zephira/commands/model.rb

Class Method Summary collapse

Class Method Details

.descriptionObject



11
12
13
# File 'lib/zephira/commands/model.rb', line 11

def description
  "List available models or switch: /model set MODEL_NAME"
end

.nameObject



7
8
9
# File 'lib/zephira/commands/model.rb', line 7

def name
  "model"
end

.run(agent:, args:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zephira/commands/model.rb', line 15

def run(agent:, args:)
  model_classes = Zephira::Models.available

  if args.nil? || args.empty?
    puts "Available models:"
    model_classes.each do |model|
      marker = (model == agent.model) ? "*" : " "
      suffix = (model == agent.model) ? " (current)" : ""
      puts "  #{marker} #{model.model_name}#{suffix}"
    end
    puts
    return
  end

  parts = args.dup
  parts.shift if parts.first.to_s.casecmp("set").zero?
  model_name = parts.first

  if model_name.nil? || model_name.strip.empty?
    puts "Usage: /model set MODEL_NAME"
    return
  end

  target = Zephira::Models.find_by_name(model_name)

  if target
    agent.model = target
    puts "Model changed to #{target.model_name}"
  else
    puts "Unknown model '#{model_name}'. Available models:"
    model_classes.each { |model| puts "    #{model.model_name}" }
  end
end