Commit f8e0591

mo khan <mo@mokhan.ca>
2026-01-07 18:50:56
fix: raise error for not claude models in vertex ai provider
1 parent 94db6df
Changed files (1)
lib
lib/net/llm/vertex_ai.rb
@@ -9,19 +9,27 @@ module Net
         @project_id = project_id
         @region = region
         @model = model
-        @claude = Claude.new(
-          endpoint: "https://#{region}-aiplatform.googleapis.com/v1/projects/#{project_id}/locations/#{region}/publishers/anthropic/models/#{model}:rawPredict",
-          headers: -> { { "Authorization" => "Bearer #{access_token}" } },
-          http: http,
-          anthropic_version: "vertex-2023-10-16"
-        )
+        @handler = build_handler(http)
       end
 
-      def messages(...) = @claude.messages(...)
-      def fetch(...) = @claude.fetch(...)
+      def messages(...) = @handler.messages(...)
+      def fetch(...) = @handler.fetch(...)
 
       private
 
+      def build_handler(http)
+        if model.start_with?("claude-")
+          Claude.new(
+            endpoint: "https://#{region}-aiplatform.googleapis.com/v1/projects/#{project_id}/locations/#{region}/publishers/anthropic/models/#{model}:rawPredict",
+            headers: -> { { "Authorization" => "Bearer #{access_token}" } },
+            http: http,
+            anthropic_version: "vertex-2023-10-16"
+          )
+        else
+          raise NotImplementedError, "Model '#{model}' is not yet supported. Only Claude models (claude-*) are currently implemented."
+        end
+      end
+
       def access_token
         @access_token ||= `gcloud auth application-default print-access-token`.strip
       end