Class: RubyLLM::Providers::VertexAI::Anthropic

Inherits:
RubyLLM::Protocols::Anthropic show all
Defined in:
lib/ruby_llm/providers/vertexai/anthropic.rb,
lib/ruby_llm/providers/vertexai/anthropic/batches.rb

Overview

The Anthropic protocol over Vertex AI rawPredict endpoints.

Defined Under Namespace

Modules: Batches

Constant Summary collapse

ANTHROPIC_VERSION =
'vertex-2023-10-16'

Constants inherited from RubyLLM::Protocols::Anthropic

RubyLLM::Protocols::Anthropic::MAX_PAUSE_TURN_CONTINUATIONS, RubyLLM::Protocols::Anthropic::SERVER_TOOL_ALIASES

Instance Attribute Summary

Attributes inherited from RubyLLM::Protocol

#config, #connection, #model, #provider

Instance Method Summary collapse

Methods inherited from RubyLLM::Protocols::Anthropic

#complete, #server_tool_aliases

Methods inherited from RubyLLM::Protocol

abstract, #animate_later, #apply_compaction, #apply_compaction_headers, #apply_end_user, #cache_content, #compact, #complete, #delete_cache, #embed, #extend_cache, #find_cache, #initialize, #list_models, #moderate, #ocr, #paint, #parse_error, #parse_image_responses, #post_image, #post_video, #preprocess_message, #raise_transcription_streaming_unsupported, #refresh_video_job, #render, #render_embedding, #render_transcription_options, #render_video_extension_payload, #rerank, #server_tool_aliases, #speak, #stream_speech, #stream_speech_response, #stream_transcription, #supports_embedding_media?, #tokenize, #tool_approval_response, #transcribe, #video_extension_attachment, #video_extension_url, #video_request_url

Methods included from RubyLLM::Protocol::BinaryStreaming

#stream_binary

Methods included from RubyLLM::Protocol::Streaming

build_on_data_handler, build_stream_error_response, error_chunk?, failed_http_status, faraday_1?, handle_data, handle_error_chunk, handle_error_event, handle_failed_response, handle_json_error_chunk, handle_sse, handle_stream, json_error_payload?, parse_error_from_json, parse_streaming_error, process_stream_chunk, raise_stream_error, stream_events, stream_response, stream_state

Constructor Details

This class inherits a constructor from RubyLLM::Protocol

Instance Method Details

#completion_urlObject



10
11
12
# File 'lib/ruby_llm/providers/vertexai/anthropic.rb', line 10

def completion_url
  "#{@provider.model_path(@model.id, publisher: 'anthropic')}:rawPredict"
end

#count_tokensObject

Raises:



24
25
26
# File 'lib/ruby_llm/providers/vertexai/anthropic.rb', line 24

def count_tokens(*, **)
  raise Error, "#{@provider.name} doesn't support token counting for Claude models"
end

#render_payload(messages) ⇒ Object



18
19
20
21
22
# File 'lib/ruby_llm/providers/vertexai/anthropic.rb', line 18

def render_payload(messages, **)
  payload = super
  payload.delete(:model)
  payload.merge(anthropic_version: ANTHROPIC_VERSION)
end

#stream_urlObject



14
15
16
# File 'lib/ruby_llm/providers/vertexai/anthropic.rb', line 14

def stream_url
  "#{@provider.model_path(@model.id, publisher: 'anthropic')}:streamRawPredict"
end

#supports_provider_file_references?Boolean

Returns:

  • (Boolean)


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

def supports_provider_file_references?
  false
end