Class: ActiveAgent::Providers::AnthropicProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- ActiveAgent::Providers::AnthropicProvider
- 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.
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
- #client ⇒ Anthropic::Client
-
#initialize(kwargs = {}) ⇒ AnthropicProvider
constructor
A new instance of AnthropicProvider.
Methods inherited from BaseProvider
#embed, embed_request_type, namespace, options_klass, #preview, #prompt, prompt_request_type, service_name, tag_name
Methods included from ToolChoiceClearing
Methods included from Previewable
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
#client ⇒ Anthropic::Client
TODO:
Add support for Anthropic::BedrockClient and Anthropic::VertexClient
33 34 35 |
# File 'lib/active_agent/providers/anthropic_provider.rb', line 33 def client ::Anthropic::Client.new(**.serialize) end |