Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added vertex to list of supported providers

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Dec 17, 2025 10:44pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 17, 2025

Greptile Summary

This PR adds Vertex AI as a new supported provider for accessing Google's Gemini models through Google Cloud Platform's Vertex AI service. The implementation is substantial but well-structured, following established patterns from the existing Google provider while adding GCP-specific authentication and endpoint configuration.

Key Changes:

  • Added new vertex provider with full support for Gemini models (gemini-3-pro-preview, gemini-2.5-pro, gemini-2.0-flash, etc.)
  • Implemented comprehensive tool calling with forced tool usage support and 20-iteration loop protection
  • Added streaming and non-streaming response modes with proper function call detection
  • Extracted shared Gemini utilities (convertToGeminiFormat, extractFunctionCall, cleanSchemaForGemini) to apps/sim/providers/google/utils.ts for reuse between google and vertex providers
  • Integrated Vertex configuration throughout the stack: environment variables (VERTEX_PROJECT, VERTEX_LOCATION), API routes, agent blocks, and copilot
  • Enhanced reasoning effort and verbosity capabilities with dynamic fetching based on selected model
  • Updated model definitions with new Gemini 3 and 2.0 models, plus reasoning effort values for o-series models

Architecture:
The implementation properly separates concerns by reusing Google/Gemini format conversion utilities while maintaining vertex-specific logic for authentication (GCP access tokens via gcloud auth print-access-token), endpoint construction (region-specific aiplatform.googleapis.com URLs), and streaming. The provider follows the same tool execution pattern as other providers with proper iteration limits and forced tool tracking.

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations
  • The implementation is comprehensive and follows established patterns from existing providers. The code reuses well-tested utilities from the Google provider and properly handles edge cases like tool calling loops, streaming with function calls, and structured output. The integration is thorough across all layers (API routes, blocks, environment config). The main consideration is the substantial code duplication in vertex/index.ts compared to google/index.ts (which the team has intentionally chosen per previous review comments), and the need for manual testing of the GCP-specific authentication flow.
  • No files require special attention - the implementation is solid across all changed files

Important Files Changed

Filename Overview
apps/sim/providers/vertex/index.ts New Vertex AI provider implementation with full tool calling, streaming, and structured output support
apps/sim/providers/vertex/utils.ts Vertex AI utility functions for stream handling and endpoint building, reusing google utils
apps/sim/providers/google/utils.ts Extracted shared utilities for Gemini API format conversion and response parsing
apps/sim/providers/models.ts Added Vertex AI provider definition with Gemini models and updated reasoning effort values
apps/sim/providers/utils.ts Registered vertex provider and added helper functions for reasoning effort and verbosity
apps/sim/blocks/blocks/agent.ts Added dynamic reasoning effort and verbosity options, plus Vertex AI project/location parameters

Sequence Diagram

sequenceDiagram
    participant User
    participant API as API Route
    participant Provider as Vertex Provider
    participant Utils as Vertex Utils
    participant Google as Google Utils
    participant Vertex as Vertex AI API
    participant Tools as Tool Executor

    User->>API: POST /api/providers (vertex request)
    API->>API: Extract vertexProject, vertexLocation
    API->>Provider: executeRequest(request)
    
    Provider->>Provider: Validate vertexProject & apiKey
    Provider->>Google: convertToGeminiFormat(request)
    Google-->>Provider: contents, tools, systemInstruction
    
    Provider->>Google: cleanSchemaForGemini(schema)
    Google-->>Provider: cleaned schema
    
    Provider->>Utils: buildVertexEndpoint(project, location, model, streaming)
    Utils-->>Provider: endpoint URL
    
    Provider->>Vertex: POST endpoint (payload with tools)
    Vertex-->>Provider: response with function call
    
    alt Has Function Call
        loop Until no more tool calls (max 20 iterations)
            Provider->>Google: extractFunctionCall(candidate)
            Google-->>Provider: functionCall
            
            Provider->>Tools: executeTool(functionCall)
            Tools-->>Provider: tool result
            
            Provider->>Vertex: POST with tool result
            Vertex-->>Provider: next response
        end
    end
    
    alt Streaming Response
        Provider->>Utils: createReadableStreamFromVertexStream(response)
        Utils->>Google: extractTextContent(candidate)
        Google-->>Utils: text content
        Utils-->>Provider: ReadableStream
        Provider-->>API: StreamingExecution
    else Non-Streaming Response
        Provider->>Google: extractTextContent(candidate)
        Google-->>Provider: content
        Provider-->>API: ProviderResponse
    end
    
    API-->>User: Response with content & metadata
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

30 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1 waleedlatif1 merged commit 7b5405e into staging Dec 17, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/vertex branch December 17, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants