Class: Strata::CLI::AI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/strata/cli/ai/configuration.rb

Constant Summary collapse

PROVIDERS =
RubyLLM::Providers.constants.map { |c| c.to_s.downcase }.sort.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
# File 'lib/strata/cli/ai/configuration.rb', line 12

def initialize
  @provider = CLI.config["ai_provider"] || default_provider
  @api_key = CLI.config["ai_api_key"]
  @model = CLI.config["ai_model"]
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



10
11
12
# File 'lib/strata/cli/ai/configuration.rb', line 10

def api_key
  @api_key
end

#modelObject (readonly)

Returns the value of attribute model.



10
11
12
# File 'lib/strata/cli/ai/configuration.rb', line 10

def model
  @model
end

#providerObject (readonly)

Returns the value of attribute provider.



10
11
12
# File 'lib/strata/cli/ai/configuration.rb', line 10

def provider
  @provider
end

Instance Method Details

#default_modelObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/strata/cli/ai/configuration.rb', line 26

def default_model
  case @provider
  when "gemini" then "gemini-2.0-flash"
  when "openai" then "gpt-4o-mini"
  when "anthropic" then "claude-sonnet-4-20250514"
  when "mistral" then "mistral-large-latest"
  when "deepseek" then "deepseek-chat"
  else
    # For other providers, we don't have a specific default.
    # The user should specify a model in .strata or via CLI if needed.
    # Returning nil here might cause issues if a default is expected,
    # so we'll return a safe fallback or let the provider helper handle it.
    nil
  end
end

#default_providerObject



22
23
24
# File 'lib/strata/cli/ai/configuration.rb', line 22

def default_provider
  "gemini"
end

#enabled?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/strata/cli/ai/configuration.rb', line 18

def enabled?
  CLI.config["ai_enabled"] != false && !@api_key.nil? && !@api_key.empty?
end

#model_or_defaultObject



42
43
44
# File 'lib/strata/cli/ai/configuration.rb', line 42

def model_or_default
  @model || default_model
end