Comparing changes

v0.2.0 v0.2.1
3 commits 4 files changed
Changed files (4)
lib/elelem/anthropic/client.rb → lib/elelem/anthropic/provider.rb
@@ -2,7 +2,7 @@
 
 module Elelem
   module Anthropic
-    class Client
+    class Provider
       def initialize(endpoint:, headers:, model:, version: nil, read_timeout: 3600, open_timeout: 10)
         @uri = URI.parse(endpoint)
         @headers_source = headers
lib/elelem/anthropic/version.rb
@@ -2,6 +2,6 @@
 
 module Elelem
   module Anthropic
-    VERSION = "0.2.0"
+    VERSION = "0.2.1"
   end
 end
lib/elelem/anthropic.rb
@@ -5,16 +5,28 @@ require "json"
 require "net/http"
 require "uri"
 
+require_relative "anthropic/provider"
 require_relative "anthropic/version"
-require_relative "anthropic/client"
 
 Elelem.configure do |config|
   config.provider(:anthropic) do
     api_key = ENV.fetch("ANTHROPIC_API_KEY")
-    Elelem::Anthropic::Client.new(
+    Elelem::Anthropic::Provider.new(
       endpoint: "https://api.anthropic.com/v1/messages",
       headers: { "x-api-key" => api_key, "anthropic-version" => "2023-06-01" },
       model: ENV.fetch("ANTHROPIC_MODEL", "claude-opus-4-5-20250514")
     )
   end
+
+  config.provider(:vertex) do
+    model = ENV.fetch("VERTEX_MODEL", "claude-opus-4-5@20251101")
+    project = ENV.fetch("GOOGLE_CLOUD_PROJECT")
+    region = ENV.fetch("GOOGLE_CLOUD_REGION", "us-east5")
+    Elelem::Anthropic::Provider.new(
+      endpoint: "https://#{region}-aiplatform.googleapis.com/v1/projects/#{project}/locations/#{region}/publishers/anthropic/models/#{model}:rawPredict",
+      headers: -> { { "Authorization" => "Bearer #{`gcloud auth application-default print-access-token`.strip}" } },
+      model: model,
+      version: "vertex-2023-10-16"
+    )
+  end
 end
Gemfile.lock
@@ -1,7 +1,7 @@
 PATH
   remote: .
   specs:
-    elelem-anthropic (0.2.0)
+    elelem-anthropic (0.2.1)
       elelem (~> 0.11)
       json (~> 3.0)
       net-http (~> 0.9)
@@ -11,8 +11,9 @@ GEM
   remote: https://rubygems.org/
   specs:
     bigdecimal (4.1.2)
-    elelem (0.13.0)
+    elelem (0.11.0)
       erb (~> 6.0)
+      forwardable (~> 1.4)
       io-console (~> 0.9)
       json (~> 3.0)
       json_schemer (~> 2.5)
@@ -24,6 +25,7 @@ GEM
       shellwords (~> 0.2)
       uri (~> 1.0)
     erb (6.0.7)
+    forwardable (1.4.0)
     hana (1.3.7)
     io-console (0.9.2)
     irb (1.18.0)
@@ -77,9 +79,10 @@ DEPENDENCIES
 CHECKSUMS
   bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
   bundler (4.0.20) sha256=7978a8ac648767f5e635bc522445b79e80a52b907a39a36c2d8085ed6bc762ae
-  elelem (0.13.0)
-  elelem-anthropic (0.2.0)
+  elelem (0.11.0) sha256=552cafb092320e3896b8e07572d322fe2b94f0f10d965bf7b993b74517a6f744
+  elelem-anthropic (0.2.1)
   erb (6.0.7) sha256=c5ca6dc25b0ef974a44dc8f59fe847577122483b1968a38dec305c60bf91ee92
+  forwardable (1.4.0) sha256=f1cd40cc9812937980e1c76f1aa053660990a7c9b6a98fc37d945468afcce838
   hana (1.3.7) sha256=5425db42d651fea08859811c29d20446f16af196308162894db208cac5ce9b0d
   io-console (0.9.2) sha256=efa74f891dd03c0939a931dfc6e74c2813d904763d456ea9762b0525e748db08
   irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3