Class: ActiveAgent::Providers::AnthropicProvider

Inherits:
BaseProvider
  • Object
show all
Defined in:
lib/active_agent/providers/anthropic_provider.rb

Overview

Handles communication with Anthropic’s Claude models.

Supports message creation, streaming responses, tool calling, and Claude-specific features like thinking mode and content blocks. Manages tool choice cleanup to prevent endless looping when tools have been used in conversation history.

See Also:

Constant Summary collapse

JSON_RESPONSE_FORMAT_LEAD_IN =

Lead-in message for JSON response format emulation

"Here is the JSON requested:\n{"

Instance Method Summary collapse

Methods inherited from BaseProvider

#embed, embed_request_type, namespace, options_klass, #preview, #prompt, prompt_request_type, service_name, tag_name

Methods included from ToolChoiceClearing

#prepare_prompt_request_tools

Methods included from Previewable

#preview_prompt

Methods included from Instrumentation

#instrumentation_prompt_payload

Methods included from ExceptionHandler

#configure_exception_handler, #rescue_with_handler, #with_exception_handling

Constructor Details

#initialize(kwargs = {}) ⇒ AnthropicProvider

Returns a new instance of AnthropicProvider.



25
26
27
28
29
# File 'lib/active_agent/providers/anthropic_provider.rb', line 25

def initialize(kwargs = {})
  super

  self.json_format_retry_count = kwargs[:max_retries] || ::Anthropic::Client::DEFAULT_MAX_RETRIES
end

Instance Method Details

#clientAnthropic::Client

TODO:

Add support for Anthropic::BedrockClient and Anthropic::VertexClient

Returns:

  • (Anthropic::Client)


33
34
35
# File 'lib/active_agent/providers/anthropic_provider.rb', line 33

def client
  ::Anthropic::Client.new(**options.serialize)
end