Class: RubyLLM::Providers::VertexAI

Inherits:
Gemini show all
Includes:
Chat, Embeddings, Models, Streaming, Transcription
Defined in:
lib/ruby_llm/providers/vertexai.rb,
lib/ruby_llm/providers/vertexai/chat.rb,
lib/ruby_llm/providers/vertexai/models.rb,
lib/ruby_llm/providers/vertexai/streaming.rb,
lib/ruby_llm/providers/vertexai/embeddings.rb,
lib/ruby_llm/providers/vertexai/transcription.rb

Overview

Google Vertex AI implementation

Defined Under Namespace

Modules: Chat, Embeddings, Models, Streaming, Transcription

Constant Summary

Constants included from Models

Models::KNOWN_GOOGLE_MODELS

Constants included from Gemini::Transcription

Gemini::Transcription::DEFAULT_PROMPT

Instance Attribute Summary

Attributes inherited from RubyLLM::Provider

#config, #connection

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models

#list_models

Methods included from Embeddings

embedding_url, parse_embedding_response, render_embedding_payload

Methods included from Streaming

#stream_url

Methods included from Chat

#completion_url

Methods inherited from Gemini

#attachment_filename, #build_file_attachment, #build_inline_attachment, #build_response_content, capabilities

Methods included from Gemini::Media

format_attachment, format_content, format_text, format_text_file

Methods included from Gemini::Tools

#extract_tool_calls, #format_tool_call, #format_tool_result, #format_tools

Methods included from Gemini::Streaming

#build_chunk, #stream_url

Methods included from Gemini::Transcription

#transcribe

Methods included from Gemini::Models

models_url, parse_list_models_response

Methods included from Gemini::Images

#images_url, #parse_image_response, #render_image_payload

Methods included from Gemini::Embeddings

embedding_url, parse_embedding_response, render_embedding_payload

Methods included from Gemini::Chat

completion_url, render_payload

Methods inherited from RubyLLM::Provider

#capabilities, capabilities, #complete, #configuration_requirements, #configured?, configured?, configured_providers, configured_remote_providers, #embed, for, #format_messages, #format_tool_calls, #list_models, #local?, local?, local_providers, #moderate, #name, name, #paint, #parse_error, #parse_tool_calls, providers, register, remote?, #remote?, remote_providers, resolve, slug, #slug, #transcribe

Methods included from Streaming

handle_stream, stream_response

Constructor Details

#initialize(config) ⇒ VertexAI



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

def initialize(config)
  super
  @authorizer = nil
end

Class Method Details

.configuration_requirementsObject



34
35
36
# File 'lib/ruby_llm/providers/vertexai.rb', line 34

def configuration_requirements
  i[vertexai_project_id vertexai_location]
end

Instance Method Details

#api_baseObject



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

def api_base
  "https://#{@config.vertexai_location}-aiplatform.googleapis.com/v1beta1"
end

#headersObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby_llm/providers/vertexai.rb', line 22

def headers
  if defined?(VCR) && !VCR.current_cassette.recording?
    { 'Authorization' => 'Bearer test-token' }
  else
    initialize_authorizer unless @authorizer
    @authorizer.apply({})
  end
rescue Google::Auth::AuthorizationError => e
  raise UnauthorizedError.new(nil, "Invalid Google Cloud credentials for Vertex AI: #{e.message}")
end