feat: configurable embedding provider, model, and dimensions via environment variables#77
Open
Ashwin-3cS wants to merge 2 commits into
Open
Conversation
Five new env vars (EMBEDDING_API_KEY/BASE/MODEL/DIMENSIONS, LLM_MODEL) so self-hosters can swap providers without code changes. Falls back to OPENAI_* when unset. Recall cache key now keyed on effective base+model. Boot WARN when schema vector dim doesn't match EMBEDDING_DIMENSIONS.
a357263 to
34ef728
Compare
Adds EMBEDDING_API_KEY / BASE / MODEL / DIMENSIONS and LLM_MODEL to environment-variables.md (Optional table + notes) and self-hosting.md (new Embedding & LLM Provider subsection). Notes the EMBEDDING_DIMENSIONS / schema dim match requirement and the recall cache key invalidation behaviour.
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.
Description
The server currently hardcodes
openai/text-embedding-3-smallfor embeddings andopenai/gpt-4o-minifor LLM calls. This limits flexibility for self-hosters who may want to:1024for Jina v3)At the moment, achieving this requires modifying the source code.
Changes
Configuration (
types.rs)Adds five new
Configfields, all read from environment variables:This improves flexibility for developers in the ecosystem by allowing different providers, models, and configurations without modifying source code.
Embedding + LLM usage (
routes.rs)generate_embedding()now uses a fallback chain:EMBEDDING_API_KEY → OPENAI_API_KEYEMBEDDING_API_BASE → OPENAI_API_BASEdimensionsfield to embedding API requestskip_serializing_if = "Option::is_none"for provider compatibilityconfig.llm_modelin all call sitesEMBEDDING_DIMENSIONSfor consistency in dev/testServer startup (
main.rs)WARNifEMBEDDING_DIMENSIONSdoes not match the schema column dimensionEnvironment config (
.env.example)Documentation (
docs/)environment-variables.mdself-hosting.mdDocumentation has been updated to reflect these changes. If any adjustments or clarifications are needed, feel free to point them out and I'll follow up in this PR.
Backwards Compatibility
All new variables have defaults that preserve the current behavior.
Existing deployments with no
.envchanges remain unaffected.Test
EMBEDDING_MODEL=jina-embeddings-v3,EMBEDDING_DIMENSIONS=1024)