Class: Riffer::Providers::Anthropic

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/providers/anthropic.rb

Overview

Anthropic provider for Claude models via the Anthropic API. Requires the anthropic gem.

Constant Summary collapse

WEB_SEARCH_TOOL_TYPE =

: String

"web_search_20250305"
FINISH_REASONS =
{
  "end_turn" => :stop,
  "stop_sequence" => :stop,
  "max_tokens" => :length,
  "tool_use" => :tool_calls,
  "refusal" => :content_filter
}.freeze

Constants inherited from Base

Base::WIRE_SEPARATOR

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#generate_text, #stream_text

Constructor Details

#initialize(api_key: nil, **options) ⇒ Anthropic

– : (?api_key: String?, **untyped) -> void



34
35
36
37
38
39
40
# File 'lib/riffer/providers/anthropic.rb', line 34

def initialize(api_key: nil, **options)
  depends_on "anthropic"

  api_key ||= Riffer.config.anthropic.api_key

  @client = ::Anthropic::Client.new(api_key: api_key, **options)
end

Class Method Details

.semconv_provider_nameObject

The GenAI semconv well-known provider name. – : () -> String



28
29
30
# File 'lib/riffer/providers/anthropic.rb', line 28

def self.semconv_provider_name
  "anthropic"
end

.skills_adapter(model = nil) ⇒ Object

Returns the XML skill adapter for Anthropic/Claude.

– : (?String?) -> singleton(Riffer::Skills::Adapter)



21
22
23
# File 'lib/riffer/providers/anthropic.rb', line 21

def self.skills_adapter(model = nil)
  Riffer::Skills::XmlAdapter
end