Class: Soapstone::AI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/soapstone/core/ai/client.rb

Constant Summary collapse

PROVIDERS =
{
  "open_ai" => Soapstone::AI::OpenAIProvider,
  "anthropic" => Soapstone::AI::AnthropicProvider
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(provider: nil) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
# File 'lib/soapstone/core/ai/client.rb', line 7

def initialize(provider: nil)
  @config = Soapstone::Config::Load.call
  return if ai_is_not_enabled?

  @provider_class = PROVIDERS[default_provider]
end

Instance Method Details

#generate_commit_message(prompt) ⇒ Object



14
15
16
17
18
19
# File 'lib/soapstone/core/ai/client.rb', line 14

def generate_commit_message(prompt)
  raise "No API key configured for AI provider" if default_api_key.nil?

  provider = @provider_class.new(api_key: default_api_key)
  provider.generate_commit_message(prompt)
end