Class: Ace::LLM::CLI::Commands::Query

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/llm/cli/commands/query.rb

Overview

Query command for ace-llm

Instance Method Summary collapse

Instance Method Details

#call(provider_model: nil, prompt_text: nil, **options) ⇒ Object



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
# File 'lib/ace/llm/cli/commands/query.rb', line 40

def call(provider_model: nil, prompt_text: nil, **options)
  if options[:version]
    puts "ace-llm #{Ace::LLM::VERSION}"
    return
  end

  if options[:list_providers]
    list_providers
    return
  end

  @provider_model = provider_model
  if @provider_model.nil? && options[:model]
    @provider_model = options[:model]
    @model_from_option = true
  end

  @prompt = options[:prompt] || prompt_text

  return show_help if @provider_model.nil? && @prompt.nil?
  return show_provider_help if @prompt.nil? || @prompt.empty?
  return show_help if @provider_model.nil? || @provider_model.empty?

  display_config_summary(options)
  execute_query(options)
rescue Ace::LLM::Error => e
  raise Ace::Support::Cli::Error.new(e.message)
rescue ArgumentError, EncodingError => e
  raise Ace::Support::Cli::Error.new(e.message)
end