fix: resolve vector dimension mismatch error when switching embedding models (#5616) #5617
+314
−65
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.
Description
Fixes #5616
This PR resolves the vector dimension error that occurs when switching between embedding models with different vector dimensions (e.g., from 2048-dimension models to Google Gemini's 768-dimension model).
Problem
When users switched from a high-dimensional embedding model (2048 dimensions) to a lower-dimensional model like Google Gemini (768 dimensions), the Qdrant vector store would fail to recreate the collection, resulting in:
Solution
Enhanced the QdrantVectorStore with robust dimension mismatch handling:
Key Changes Made
Enhanced Collection Recreation Logic
Improved Error Reporting
cause
propertyRobust Verification Process
Files Changed
src/services/code-index/vector-store/qdrant-client.ts
- Enhanced collection recreation logicsrc/services/code-index/vector-store/__tests__/qdrant-client.spec.ts
- Added comprehensive test coverageTesting
Verification of Acceptance Criteria
Impact
Checklist
Important
Fixes vector dimension mismatch error in
QdrantVectorStore
by enhancing collection recreation logic and error handling.QdrantVectorStore
.qdrant-client.ts
.qdrant-client.spec.ts
for dimension mismatch scenarios._recreateCollectionWithNewDimension()
and_createPayloadIndexes()
to handle collection recreation and index creation.initialize()
to handle dimension mismatches and improve error handling.This description was created by
for 5da7606. You can customize this summary. It will automatically update as commits are pushed.