Module: AIA::Directives::Configuration

Defined in:
lib/aia/directives/configuration.rb

Class Method Summary collapse

Class Method Details

.config(args = [], context_manager = nil) ⇒ Object Also known as: cfg



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aia/directives/configuration.rb', line 6

def self.config(args = [], context_manager = nil)
  args = Array(args)

  if args.empty?
    ap AIA.config
    ""
  elsif args.length == 1
    config_item = args.first
    local_cfg = Hash.new
    local_cfg[config_item] = AIA.config[config_item]
    ap local_cfg
    ""
  else
    config_item = args.shift
    boolean = AIA.respond_to?("#{config_item}?")
    new_value = args.join(' ').gsub('=', '').strip

    if boolean
      new_value = %w[true t yes y on 1 yea yeah yep yup].include?(new_value.downcase)
    end

    AIA.config[config_item] = new_value
    ""
  end
end

.model(args, context_manager = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/aia/directives/configuration.rb', line 32

def self.model(args, context_manager = nil)
  if args.empty?
    # Display details for all configured models
    puts
    models = Array(AIA.config.model)

    if models.size == 1
      puts "Current Model:"
      puts "=============="
      puts AIA.config.client.model.to_h.pretty_inspect
    else
      puts "Multi-Model Configuration:"
      puts "=========================="
      puts "Model count: #{models.size}"
      puts "Primary model: #{models.first} (used for consensus when --consensus flag is enabled)"
      puts "Consensus mode: #{AIA.config.consensus.nil? ? 'auto-detect (disabled by default)' : AIA.config.consensus}"
      puts
      puts "Model Details:"
      puts "-" * 50

      models.each_with_index do |model_name, index|
        puts "#{index + 1}. #{model_name}#{index == 0 ? ' (primary)' : ''}"

        # Try to get model details if available
        begin
          # Access the model details from RubyLLM's model registry
          model_info = RubyLLM::Models.find(name: model_name)
          if model_info
            puts "   Provider: #{model_info.provider || 'Unknown'}"
            puts "   Context window: #{model_info.context_window || 'Unknown'}"
            puts "   Input cost: $#{model_info.input_cost || 'Unknown'}"
            puts "   Output cost: $#{model_info.output_cost || 'Unknown'}"
            puts "   Mode: #{model_info.modalities || 'Unknown'}"
            puts "   Capabilities: #{(model_info.capabilities || []).join(', ')}" if model_info.capabilities&.any?
          else
            puts "   Details: Model not found in registry"
          end
        rescue StandardError => e
          puts "   Details: Unable to fetch (#{e.class.name}: #{e.message})"
        end
        puts
      end
    end
    puts
  else
    send(:config, args.prepend('model'), context_manager)
  end

  return ''
end

.temperature(args, context_manager = nil) ⇒ Object Also known as: temp



83
84
85
# File 'lib/aia/directives/configuration.rb', line 83

def self.temperature(args, context_manager = nil)
  send(:config, args.prepend('temperature'), context_manager)
end

.top_p(args, context_manager = nil) ⇒ Object Also known as: topp



87
88
89
# File 'lib/aia/directives/configuration.rb', line 87

def self.top_p(args, context_manager = nil)
  send(:config, args.prepend('top_p'), context_manager)
end