Class: Soapstone::AI::AnthropicProvider

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, model: "claude-3-haiku-20240307", **options) ⇒ AnthropicProvider

Returns a new instance of AnthropicProvider.



2
3
4
5
# File 'lib/soapstone/core/ai/anthropic_provider.rb', line 2

def initialize(api_key:, model: "claude-3-haiku-20240307", **options)
  @client = Anthropic::Client.new(api_key: api_key)
  @model = options[:model] || model
end

Instance Method Details

#generate_commit_message(prompt) ⇒ Object



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

def generate_commit_message(prompt)
  response = make_anthropic_request(prompt.system, prompt.user)
  parse_response(response)
rescue => e
  "AI generation failed: #{e.message}"
end