fix: add batch size limiting for Qwen embeddings via OpenAI-compatible interface #9143
+312
−2
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.
This PR attempts to address Issue #9142. Feedback and guidance are welcome.
Problem
When using Qwen3-Embedding via Alibaba Cloud's OpenAI-compatible interface, users encounter an HTTP 400 error stating that the batch size should not be larger than 10. The embedding service was sending batches based only on token limits, without considering the item count limit.
Solution
maxBatchSizeparameter to theOpenAICompatibleEmbedderclasstext-embedding-v*patterns used by Alibaba Cloud)Changes
Modified
src/services/code-index/embedders/openai-compatible.ts:maxBatchSizeproperty and constructor parameterisQwenModel()method to detect Qwen and Alibaba Cloud modelsAdded
src/services/code-index/embedders/__tests__/openai-compatible-batch-size.spec.ts:Testing
Fixes #9142
Important
Adds batch size limiting for Qwen models in
OpenAICompatibleEmbedderwith automatic detection and comprehensive tests.maxBatchSizeparameter toOpenAICompatibleEmbedderto limit batch size for Qwen models.openai-compatible.tsto respect both token and item count limits.openai-compatible-batch-size.spec.tswith tests for Qwen model detection, batch size limits, and custom batch size configuration.isQwenModel()method inopenai-compatible.tsto identify Qwen models.This description was created by
for d08c5c2. You can customize this summary. It will automatically update as commits are pushed.