feat(embedding): support provider-agnostic OpenAI-compat endpoint#153
Closed
MichaelChristopher wants to merge 1 commit intogarrytan:masterfrom
Closed
feat(embedding): support provider-agnostic OpenAI-compat endpoint#153MichaelChristopher wants to merge 1 commit intogarrytan:masterfrom
MichaelChristopher wants to merge 1 commit intogarrytan:masterfrom
Conversation
Read model/dimensions/baseURL from env vars so gbrain can route embeddings through local Ollama (nomic-embed-text) or any OpenAI-compat provider instead of hard-coding OpenAI text-embedding-3-large. Env vars added: - GBRAIN_EMBED_MODEL (default: text-embedding-3-large) - GBRAIN_EMBED_DIMENSIONS (default: 1536) - OPENAI_BASE_URL (for non-OpenAI providers) The dimensions parameter is only sent when the model name starts with "text-embedding-" (OpenAI-native Matryoshka truncation). Non-OpenAI providers do not support this parameter. Local patch 0001/0004 for Phase B gbrain adoption. Co-Authored-By: Claude Opus 4.6 (1M context) <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
Adds environment variable support for configuring embedding providers, enabling local models (Ollama, llama.cpp) and other OpenAI-compatible endpoints without code changes.
New env vars:
GBRAIN_EMBED_MODEL— override embedding model (default: text-embedding-3-large)GBRAIN_EMBED_DIMENSIONS— override vector dimensions (default: 1536)OPENAI_BASE_URL— point to non-OpenAI providers (e.g. http://localhost:11434/v1 for Ollama)The
dimensionsparameter is only sent for OpenAI-native models (those starting withtext-embedding-) to avoid breaking non-OpenAI providers that don't support it.Motivation
Running gbrain with local embedding models (nomic-embed-text via Ollama) currently requires patching
embedding.ts. This PR makes the provider configurable at runtime, which is useful for:Changes
src/core/embedding.ts: 8 insertions, 4 deletions