-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(code-index): remove deprecated text-embedding-004 and migrate to gemini-embedding-001 #11038
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
Open
roomote
wants to merge
4
commits into
main
Choose a base branch
from
fix/remove-text-embedding-004
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8bae469
fix(code-index): remove deprecated text-embedding-004 model and migra…
roomote 4840a86
Delete .changeset/remove-text-embedding-004.md
hannesrudolph 4335d9f
fix(code-index): keep text-embedding-004 in profiles for backward-com…
roomote 04b4a69
test(code-index): add tests for text-embedding-004 dimension lookup i…
roomote 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import { describe, it, expect } from "vitest" | ||
| import { | ||
| getModelDimension, | ||
| getModelScoreThreshold, | ||
| getDefaultModelId, | ||
| EMBEDDING_MODEL_PROFILES, | ||
| } from "../embeddingModels" | ||
|
|
||
| describe("embeddingModels", () => { | ||
| describe("EMBEDDING_MODEL_PROFILES", () => { | ||
| it("should have gemini provider with gemini-embedding-001 model", () => { | ||
| const geminiProfiles = EMBEDDING_MODEL_PROFILES.gemini | ||
| expect(geminiProfiles).toBeDefined() | ||
| expect(geminiProfiles!["gemini-embedding-001"]).toBeDefined() | ||
| expect(geminiProfiles!["gemini-embedding-001"].dimension).toBe(3072) | ||
| }) | ||
|
|
||
| it("should have deprecated text-embedding-004 in gemini profiles for backward compatibility", () => { | ||
| // This is critical for backward compatibility: | ||
| // Users with text-embedding-004 configured need dimension lookup to work | ||
| // even though the model is migrated to gemini-embedding-001 in GeminiEmbedder | ||
| const geminiProfiles = EMBEDDING_MODEL_PROFILES.gemini | ||
| expect(geminiProfiles).toBeDefined() | ||
| expect(geminiProfiles!["text-embedding-004"]).toBeDefined() | ||
| expect(geminiProfiles!["text-embedding-004"].dimension).toBe(3072) | ||
| }) | ||
| }) | ||
|
|
||
| describe("getModelDimension", () => { | ||
| it("should return dimension for gemini-embedding-001", () => { | ||
| const dimension = getModelDimension("gemini", "gemini-embedding-001") | ||
| expect(dimension).toBe(3072) | ||
| }) | ||
|
|
||
| it("should return dimension for deprecated text-embedding-004", () => { | ||
| // This ensures createVectorStore() works for users with text-embedding-004 configured | ||
| // The dimension should be 3072 (matching gemini-embedding-001) because: | ||
| // 1. GeminiEmbedder migrates text-embedding-004 to gemini-embedding-001 | ||
| // 2. gemini-embedding-001 produces 3072-dimensional embeddings | ||
| // 3. Vector store dimension must match the actual embedding dimension | ||
| const dimension = getModelDimension("gemini", "text-embedding-004") | ||
| expect(dimension).toBe(3072) | ||
| }) | ||
|
|
||
| it("should return undefined for unknown model", () => { | ||
| const dimension = getModelDimension("gemini", "unknown-model") | ||
| expect(dimension).toBeUndefined() | ||
| }) | ||
|
|
||
| it("should return undefined for unknown provider", () => { | ||
| const dimension = getModelDimension("unknown-provider" as any, "some-model") | ||
| expect(dimension).toBeUndefined() | ||
| }) | ||
|
|
||
| it("should return correct dimensions for openai models", () => { | ||
| expect(getModelDimension("openai", "text-embedding-3-small")).toBe(1536) | ||
| expect(getModelDimension("openai", "text-embedding-3-large")).toBe(3072) | ||
| expect(getModelDimension("openai", "text-embedding-ada-002")).toBe(1536) | ||
| }) | ||
| }) | ||
|
|
||
| describe("getModelScoreThreshold", () => { | ||
| it("should return score threshold for gemini-embedding-001", () => { | ||
| const threshold = getModelScoreThreshold("gemini", "gemini-embedding-001") | ||
| expect(threshold).toBe(0.4) | ||
| }) | ||
|
|
||
| it("should return score threshold for deprecated text-embedding-004", () => { | ||
| const threshold = getModelScoreThreshold("gemini", "text-embedding-004") | ||
| expect(threshold).toBe(0.4) | ||
| }) | ||
|
|
||
| it("should return undefined for unknown model", () => { | ||
| const threshold = getModelScoreThreshold("gemini", "unknown-model") | ||
| expect(threshold).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe("getDefaultModelId", () => { | ||
| it("should return gemini-embedding-001 for gemini provider", () => { | ||
| const defaultModel = getDefaultModelId("gemini") | ||
| expect(defaultModel).toBe("gemini-embedding-001") | ||
| }) | ||
|
|
||
| it("should return text-embedding-3-small for openai provider", () => { | ||
| const defaultModel = getDefaultModelId("openai") | ||
| expect(defaultModel).toBe("text-embedding-3-small") | ||
| }) | ||
|
|
||
| it("should return codestral-embed-2505 for mistral provider", () => { | ||
| const defaultModel = getDefaultModelId("mistral") | ||
| expect(defaultModel).toBe("codestral-embed-2505") | ||
| }) | ||
| }) | ||
| }) |
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
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.
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.
Removing
text-embedding-004from the profiles breaks the silent migration for users who have it configured. WhencreateVectorStore()inservice-factory.tscallsgetModelDimension("gemini", "text-embedding-004"), it will returnundefinedbecause the model is no longer in the profiles, causing an error. The migration inGeminiEmbedderonly affects embedder creation, not dimension lookup.Consider either: (1) keeping
text-embedding-004in the profiles pointing to the migrated model's dimension (3072), or (2) exporting the migration logic fromGeminiEmbedderand applying it inservice-factory.tsbefore callinggetModelDimension().Fix it with Roo Code or mention @roomote and request a fix.