Skip to content

fix(embed): split Gemini batchEmbedContents into <=100-request calls#200

Merged
jrosskopf merged 1 commit into
mainfrom
fix/gemini-batch-100
Jun 24, 2026
Merged

fix(embed): split Gemini batchEmbedContents into <=100-request calls#200
jrosskopf merged 1 commit into
mainfrom
fix/gemini-batch-100

Conversation

@jrosskopf

Copy link
Copy Markdown
Contributor

Gemini caps a batch at 100 requests; documents chunking into >100 blocks 400'd (breaks live /ingest/upload AND the offline loader's Gemini build on large PDFs). Split into <=100-text sub-batches, order preserved. Wiremock test: 150 texts → 2 calls (100+50), each <=100, all 150 vectors returned.

🤖 Generated with Claude Code

Gemini's batchEmbedContents rejects a batch with more than 100 requests
(`INVALID_ARGUMENT: at most 100 requests can be in one batch`). The embedder
sent every text of a document in one call, so any document chunking into >100
blocks 400'd — breaking both the live server's /ingest/upload AND the offline
loader's Gemini build on larger PDFs.

GeminiEmbedder::embed now splits `texts` into <=100-text sub-batches (extracted
embed_batch helper), preserving order across calls.

Test: wiremock test embeds 150 texts, asserts each sub-batch is <=100, exactly
2 calls are made (100+50), and all 150 vectors return.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jrosskopf jrosskopf merged commit f26673b into main Jun 24, 2026
@jrosskopf jrosskopf deleted the fix/gemini-batch-100 branch June 24, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant