-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: vertex/gemini prompt caching #2996
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
🦋 Changeset detectedLatest commit: 77e4df6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
src/api/providers/gemini.ts
Outdated
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.
Consider wrapping JSON.parse(this.options.vertexJsonCredentials) in a try/catch block to handle potential JSON parsing errors. This improves resiliency if invalid credentials are provided.
This comment was generated because it violated a code review rule: mrule_OR1S8PRRHcvbdFib.
Moving to @google/genai and reusing the gemini provider when using gemini on vertex ai
f867837 to
96b7921
Compare
|
Thanks for tackling this difficult problem! Even though you don't think it is perfect. We don't have to eat the elephant all in on bite. The whole troop can work on improving it now. 🦘❤️ Adding your comment from the channel Thread for completeness:
|
|
@cte are you able to review this one? Thanks! |
cte
left a comment
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.
I moved some stuff around; LMK if you any questions about my changes.
looks great! |
|
minor: seems like gemini-2.5-flash-preview-04-17 supports caching as per this doc- could be different between gemini vs vertex |
Moving to @google/genai and reusing the gemini provider when using gemini on vertex ai
Context
Use the gemini provider when using a gemini model is selected on vertex ai.
@google/genai now support both Google Gemini and Vertex AI APIs
Prompt caching is already implemented in the gemini provider
Implementation
Used the gemini provider when a gemini model is selected on vertex ai.
Screenshots
Screen.Recording.2025-04-28.at.00.02.30.mov
How to Test
Select a gemini model that supports prompt caching on vertex ai. enable prompt caching
Get in Touch
ashktn
Important
Integrates Gemini prompt caching on Vertex AI by using
GeminiHandler, updating models, and modifying tests and configurations.GeminiHandlerfor prompt caching with Gemini models on Vertex AI invertex.tsandgemini.ts.vertexModelsinapi.tsto support prompt caching for Gemini models.@google-cloud/vertexaidependency frompackage.json.vertex.test.tsto mockGeminiHandlerand test prompt caching behavior.vertex-gemini-format.test.tsandvertex-gemini-format.tsas they are no longer needed.isVertexoption toProviderSettingsinroo-code.d.ts,types.ts, andschemas/index.tsto distinguish between Gemini and Vertex AI usage.This description was created by
for f867837e867308b3e74f0cd15bf6701537d34b83. You can customize this summary. It will automatically update as commits are pushed.