-
Notifications
You must be signed in to change notification settings - Fork 460
feat: [ENG-3852] Native Gemini API Mappers on AI Gateway #5299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* add mappings for google and vertex + update usageprocessors * revert openAIUsageProcessor * revert costCalc.ts changes * revert responseBodyHandler.ts * revert some unecessary changes + console logs * file reversion * send apiKey as requestParams * Update packages/llm-mapper/transform/providers/google/response/toOpenai.ts * explanation comment * fix greptile mistake * fix tsc error * add missing semicolon --------
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @connortbot's task —— View job PR Review: Native Gemini API Mappers
|
Greptile OverviewGreptile SummaryAdds native Google Gemini API support to the AI Gateway, enabling OpenAI-to-Gemini request/response transformation for both streaming and non-streaming modes. Key Changes:
Implementation Quality:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant Worker
participant AIGateway
participant GoogleProvider
participant GoogleAPI
participant UsageProcessor
Client->>Worker: OpenAI format request
Worker->>AIGateway: Route request
AIGateway->>GoogleProvider: buildRequestBody()
GoogleProvider->>GoogleProvider: toGoogle() transform
Note over GoogleProvider: Maps messages, tools,<br/>generation config
GoogleProvider->>GoogleAPI: Native Gemini API request
alt Streaming
GoogleAPI-->>Worker: SSE stream (Google format)
Worker->>Worker: goog2oaiStream()
Note over Worker: GoogleToOpenAIStreamConverter<br/>processes chunks
Worker-->>Client: OpenAI SSE stream
else Non-streaming
GoogleAPI-->>Worker: JSON response (Google format)
Worker->>Worker: goog2oaiResponse()
Note over Worker: toOpenAI() conversion
Worker-->>Client: OpenAI format response
end
Worker->>UsageProcessor: Process usage metadata
Note over UsageProcessor: GoogleUsageProcessor extends<br/>VertexOpenAIUsageProcessor
UsageProcessor->>UsageProcessor: Extract modality tokens<br/>(text, audio, image, video)
UsageProcessor-->>Worker: Normalized usage data
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
38 files reviewed, 1 comment
| // If the parsed value is a primitive (number, string, boolean, null), wrap it | ||
| // Google's API requires functionResponse.response to be an object (Struct) | ||
| if (typeof parsed !== 'object' || parsed === null) { | ||
| return { result: parsed }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: verify that wrapping primitives in { result: value } matches Google's API expectations for functionResponse.response
the comment states Google requires an object (Struct), but confirm this is the correct field name (result) and that Google won't expect a different structure
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/llm-mapper/transform/providers/openai/request/toGoogle.ts
Line: 410:414
Comment:
**style:** verify that wrapping primitives in `{ result: value }` matches Google's API expectations for `functionResponse.response`
the comment states Google requires an object (Struct), but confirm this is the correct field name (`result`) and that Google won't expect a different structure
How can I resolve this? If you propose a fix, please make it concise.* fix package tests to test for the new gemini api response format * add bedrock vers to claude response

No description provided.