Class: Ace::LLM::Organisms::AnthropicClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- Ace::LLM::Organisms::AnthropicClient
- Defined in:
- lib/ace/llm/organisms/anthropic_client.rb
Overview
AnthropicClient handles interactions with Anthropic’s Claude API
Constant Summary collapse
- API_BASE_URL =
"https://api.anthropic.com"- DEFAULT_MODEL =
"claude-3-5-sonnet-20241022"- API_VERSION =
"2023-06-01"- GENERATION_KEYS =
Generation parameters to include in API request (max_tokens handled separately as required)
%i[temperature top_p top_k].freeze
- DEFAULT_GENERATION_CONFIG =
{ temperature: 0.7, max_tokens: 4096, # Anthropic requires max_tokens top_p: nil, top_k: nil }.freeze
Constants inherited from BaseClient
BaseClient::DEFAULT_SYSTEM_PROMPT_SEPARATOR
Instance Attribute Summary
Attributes inherited from BaseClient
#api_key, #base_url, #generation_config, #http_client, #model
Class Method Summary collapse
-
.provider_name ⇒ String
Get the provider name.
Instance Method Summary collapse
-
#generate(messages, **options) ⇒ Hash
Generate a response from Anthropic’s Claude.
Methods inherited from BaseClient
#initialize, #needs_credentials?, #provider_name
Constructor Details
This class inherits a constructor from Ace::LLM::Organisms::BaseClient
Class Method Details
.provider_name ⇒ String
Get the provider name
26 27 28 |
# File 'lib/ace/llm/organisms/anthropic_client.rb', line 26 def self.provider_name "anthropic" end |
Instance Method Details
#generate(messages, **options) ⇒ Hash
Generate a response from Anthropic’s Claude
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ace/llm/organisms/anthropic_client.rb', line 34 def generate(, **) = () generation_params = () request_body = build_request_body(, generation_params) response = make_api_request(request_body) parse_response(response) rescue => e handle_api_error(e) end |