Class: Rasti::AI::Anthropic::Provider

Inherits:
Provider
  • Object
show all
Defined in:
lib/rasti/ai/anthropic/provider.rb

Constant Summary collapse

STRUCTURED_OUTPUT_TOOL =
'structured_output'.freeze
THINKING_LEVELS =
{
  'low' => {type: 'enabled', budget_tokens: 1_024}.freeze,
  'medium' => {type: 'enabled', budget_tokens: 8_000}.freeze,
  'high' => {type: 'enabled', budget_tokens: 16_000}.freeze
}.freeze

Constants inherited from Provider

Provider::ALIASES, Provider::MODULES

Instance Attribute Summary

Attributes inherited from Provider

#model

Instance Method Summary collapse

Methods inherited from Provider

build, #build_client, #create_assistant, #generate_text, #initialize, names

Constructor Details

This class inherits a constructor from Rasti::AI::Provider

Instance Method Details

#base_urlObject



26
27
28
# File 'lib/rasti/ai/anthropic/provider.rb', line 26

def base_url
  'https://api.anthropic.com/v1'
end

#default_api_keyObject



22
23
24
# File 'lib/rasti/ai/anthropic/provider.rb', line 22

def default_api_key
  Rasti::AI.anthropic_api_key
end

#default_modelObject



18
19
20
# File 'lib/rasti/ai/anthropic/provider.rb', line 18

def default_model
  Rasti::AI.anthropic_default_model
end

#nameObject



14
15
16
# File 'lib/rasti/ai/anthropic/provider.rb', line 14

def name
  :anthropic
end

#parse_usage(response) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rasti/ai/anthropic/provider.rb', line 30

def parse_usage(response)
  usage = response['usage']
  return nil unless usage

  Usage.new(
    provider: name.to_s,
    model: response['model'],
    input_tokens: usage['input_tokens'],
    output_tokens: usage['output_tokens'],
    cached_tokens: usage['cache_read_input_tokens'] || 0,
    reasoning_tokens: 0,
    raw: usage
  )
end