Class: Desiru::Models::Anthropic

Inherits:
Base
  • Object
show all
Defined in:
lib/desiru/models/anthropic.rb

Overview

Anthropic Claude model adapter

Constant Summary collapse

DEFAULT_MODEL =
'claude-3-haiku-20240307'

Instance Attribute Summary

Attributes inherited from Base

#client, #config

Instance Method Summary collapse

Methods inherited from Base

#complete, #healthy?, #reset_stats, #stats, #stream_complete

Constructor Details

#initialize(config = {}) ⇒ Anthropic

Returns a new instance of Anthropic.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/desiru/models/anthropic.rb', line 11

def initialize(config = {})
  super
  @api_key = config[:api_key] || ENV.fetch('ANTHROPIC_API_KEY', nil)
  raise ArgumentError, 'Anthropic API key is required' unless @api_key

  @client = ::Anthropic::Client.new(access_token: @api_key)
end

Instance Method Details

#modelsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/desiru/models/anthropic.rb', line 19

def models
  # Anthropic doesn't provide a models endpoint, so we maintain a list
  # This list should be updated periodically as new models are released
  @models ||= {
    'claude-3-haiku-20240307' => {
      name: 'Claude 3 Haiku',
      max_tokens: 200_000,
      description: 'Fast and efficient for simple tasks'
    },
    'claude-3-sonnet-20240229' => {
      name: 'Claude 3 Sonnet',
      max_tokens: 200_000,
      description: 'Balanced performance and capability'
    },
    'claude-3-opus-20240229' => {
      name: 'Claude 3 Opus',
      max_tokens: 200_000,
      description: 'Most capable model for complex tasks'
    },
    'claude-3-5-sonnet-20241022' => {
      name: 'Claude 3.5 Sonnet',
      max_tokens: 200_000,
      description: 'Latest Sonnet with improved capabilities'
    },
    'claude-3-5-haiku-20241022' => {
      name: 'Claude 3.5 Haiku',
      max_tokens: 200_000,
      description: 'Latest Haiku with enhanced speed'
    }
  }
end