Class: Rasti::AI::Anthropic::Provider
- Inherits:
-
Provider
- Object
- Provider
- Rasti::AI::Anthropic::Provider
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
Instance Method Details
#base_url ⇒ Object
26
27
28
|
# File 'lib/rasti/ai/anthropic/provider.rb', line 26
def base_url
'https://api.anthropic.com/v1'
end
|
#default_api_key ⇒ Object
22
23
24
|
# File 'lib/rasti/ai/anthropic/provider.rb', line 22
def default_api_key
Rasti::AI.anthropic_api_key
end
|
#default_model ⇒ Object
18
19
20
|
# File 'lib/rasti/ai/anthropic/provider.rb', line 18
def default_model
Rasti::AI.anthropic_default_model
end
|
#name ⇒ Object
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
|