-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Vertex ai model mapping fix #27749
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
Merged
Merged
Vertex ai model mapping fix #27749
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5200c4c
add a model mapping that intercepts set models and provides their exp…
DavidAPierce d257f8e
use existing consts in new mapping for consistency
DavidAPierce 4bc56b7
fix mapping so that it doesn't try for literal strings.
DavidAPierce 3cb7926
fix failing test that referenced 3.5 flash now that the override has …
DavidAPierce b79f67a
inverted overwriting so that the special case of gemin-3-flash is tre…
DavidAPierce fc6e81d
update config tests to accept 3.5-flash as the default model name for…
DavidAPierce b43621c
update wrapping method to work with prefix. Also update unwrapping fo…
DavidAPierce 2f3d1a6
revert changes to use vertex ai and use gemini flow in content genera…
DavidAPierce 817fe9b
update tests in content Generator to properly validate model mappings…
DavidAPierce 1088e2b
Merge branch 'main' into vertex_ai_model_mapping_fix
DavidAPierce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { | ||
| type CountTokensResponse, | ||
| type GenerateContentResponse, | ||
| type GenerateContentParameters, | ||
| type CountTokensParameters, | ||
| type EmbedContentResponse, | ||
| type EmbedContentParameters, | ||
| } from '@google/genai'; | ||
| import { type ContentGenerator } from './contentGenerator.js'; | ||
| import type { LlmRole } from '../telemetry/llmRole.js'; | ||
| import type { UserTierId, GeminiUserTier } from '../code_assist/types.js'; | ||
|
|
||
| export class ModelMappingContentGenerator implements ContentGenerator { | ||
| constructor( | ||
| private readonly wrapped: ContentGenerator, | ||
| private readonly mappings: Record<string, string>, | ||
| ) {} | ||
|
|
||
| get userTier(): UserTierId | undefined { | ||
| return this.wrapped.userTier; | ||
| } | ||
|
|
||
| get userTierName(): string | undefined { | ||
| return this.wrapped.userTierName; | ||
| } | ||
|
|
||
| get paidTier(): GeminiUserTier | undefined { | ||
| return this.wrapped.paidTier; | ||
| } | ||
|
|
||
| private mapModel<T extends { model?: string }>(req: T): T { | ||
| if (req.model && this.mappings[req.model]) { | ||
| return { | ||
| ...req, | ||
| model: this.mappings[req.model], | ||
| }; | ||
| } | ||
| return req; | ||
| } | ||
|
|
||
| generateContent( | ||
| request: GenerateContentParameters, | ||
| userPromptId: string, | ||
| role: LlmRole, | ||
| ): Promise<GenerateContentResponse> { | ||
| return this.wrapped.generateContent( | ||
| this.mapModel(request), | ||
| userPromptId, | ||
| role, | ||
| ); | ||
| } | ||
|
|
||
| generateContentStream( | ||
| request: GenerateContentParameters, | ||
| userPromptId: string, | ||
| role: LlmRole, | ||
| ): Promise<AsyncGenerator<GenerateContentResponse>> { | ||
| return this.wrapped.generateContentStream( | ||
| this.mapModel(request), | ||
| userPromptId, | ||
| role, | ||
| ); | ||
| } | ||
|
|
||
| countTokens(request: CountTokensParameters): Promise<CountTokensResponse> { | ||
| return this.wrapped.countTokens(this.mapModel(request)); | ||
| } | ||
|
|
||
| embedContent(request: EmbedContentParameters): Promise<EmbedContentResponse> { | ||
| return this.wrapped.embedContent(this.mapModel(request)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.