Make EMBEDDING_MAX_CHARS provider-aware to avoid over-truncating large symbols#65
Merged
Merged
Conversation
…t window Replace the flat 6000-char default with a per-provider table keyed on EMBEDDINGS_PROVIDER's default model context window (~3 chars/token, ~10% safety margin): 22000 for the 8K-token providers (jina/jina-api/openai), 86000 for voyage-code-3's 32K window, 5500 for ollama's 2K window. A model_validator fills the value only when EMBEDDING_MAX_CHARS is unset, so the env var still overrides explicitly. Fixes under-utilization that truncated large symbols down to the smallest provider's budget. Tests: adds tests/test_config.py covering all five per-provider defaults and the explicit-override case; full suite passes (216). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
EMBEDDING_MAX_CHARSdefault with a per-provider default derived from each provider's default model's max input token limit (verified against official docs), so large-context providers (Voyage 32K, OpenAI/Jina 8K) aren't truncated down to the smallest-context provider's (Ollama 2K) budget.EMBEDDING_MAX_CHARSenv var still works as an explicit override for any provider.docs/configuration.md,docs/ingestion.md,docs/dense-vectors.md,README.md,.env.example) updated with the new per-provider table.EMBEDDINGS_PROVIDEREMBEDDING_MAX_CHARSdefaultjinajinaai/jina-embeddings-v2-base-codejina-apijina-embeddings-v2-base-codevoyagevoyage-code-3openaitext-embedding-3-largeollamanomic-embed-textFixes #64.
Test plan
uv run pytest -q— 216 passedtests/test_config.pycovers all five per-provider defaults and the explicit-override casetests/test_pipeline.py(which passesmax_charsexplicitly) unaffected🤖 Generated with Claude Code