in lib/anthropic/vertex/client.rb [38:91]
def initialize(
region: ENV["CLOUD_ML_REGION"],
project_id: ENV["ANTHROPIC_VERTEX_PROJECT_ID"],
base_url: nil,
max_retries: DEFAULT_MAX_RETRIES,
timeout: DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: DEFAULT_MAX_RETRY_DELAY
)
begin
require("googleauth")
rescue LoadError
raise <<~MSG
In order to access Anthropic models on Vertex you must require the `googleauth` gem.
You can install it by adding the following to your Gemfile:
gem "googleauth"
and then running `bundle install`.
Alternatively, if you are not using Bundler, simply run:
gem install googleauth
MSG
end
if region.to_s.empty?
raise ArgumentError,
"No region was given. The client should be instantiated with the `region` argument or the `CLOUD_ML_REGION` environment variable should be set."
end
@region = region
if project_id.to_s.empty?
raise ArgumentError,
"No project_id was given and it could not be resolved from credentials. The client should be instantiated with the `project_id` argument or the `ANTHROPIC_VERTEX_PROJECT_ID` environment variable should be set."
end
@project_id = project_id
base_url ||= ENV.fetch("ANTHROPIC_VERTEX_BASE_URL", "https://#{@region}-aiplatform.googleapis.com/v1")
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay,
)
@messages = Anthropic::Resources::Messages.new(client: self)
@beta = Anthropic::Resources::Beta.new(client: self)
end