Class: Clients::ClaudeClient
- Inherits:
-
Object
- Object
- Clients::ClaudeClient
- Defined in:
- lib/clients/claude_client.rb
Overview
Claude API client for communicating with Anthropic’s Claude model
Defined Under Namespace
Classes: ConfigError, OverloadError, UnknownError
Instance Method Summary collapse
-
#initialize ⇒ ClaudeClient
constructor
A new instance of ClaudeClient.
- #post(message) ⇒ Object
Constructor Details
#initialize ⇒ ClaudeClient
Returns a new instance of ClaudeClient.
14 15 16 17 18 19 20 21 |
# File 'lib/clients/claude_client.rb', line 14 def initialize @config = Committer::Config.load return unless @config['api_key'].nil? || @config['api_key'].empty? raise ConfigError, "API key not configured. Run 'committer setup' and edit ~/.committer/config.yml to add your API key." end |
Instance Method Details
#post(message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/clients/claude_client.rb', line 23 def post() body = { model: @config['model'], max_tokens: 4096, messages: [ { role: 'user', content: } ] } response = send_request(body) handle_error_response(response) if response['type'] == 'error' response end |