Skip to content

feat(embedding): pluggable OpenAI-compatible embedding provider#178

Closed
asperty567 wants to merge 1 commit into
garrytan:masterfrom
asperty567:link/local-embeddings
Closed

feat(embedding): pluggable OpenAI-compatible embedding provider#178
asperty567 wants to merge 1 commit into
garrytan:masterfrom
asperty567:link/local-embeddings

Conversation

@asperty567

Copy link
Copy Markdown

Adds three env overrides so gbrain can run against any OpenAI-compatible /v1/embeddings endpoint (LM Studio, Ollama, vLLM, Together, self-hosted) instead of hardcoded OpenAI.

Environment variables:
EMBEDDING_BASE_URL custom endpoint (optional)
EMBEDDING_API_KEY api key (falls back to OPENAI_API_KEY)
EMBEDDING_MODEL model name (default: text-embedding-3-large)
EMBEDDING_DIMENSIONS vector dimension (default: 1536)
EMBEDDING_SEND_DIMENSIONS auto (default): sends dimensions only
when MODEL starts with text-embedding-3

Schema templates (pglite-schema.ts, schema-embedded.ts) now interpolate EMBEDDING_MODEL and EMBEDDING_DIMENSIONS so the pgvector column and config metadata match at gbrain init time.

Forces encoding_format: float in the request. The OpenAI SDK defaults to base64 which LM Studio mis-decodes (returns 192 floats for a 768-dim nomic vector). float is spec-compliant and all providers support it.

Verified end-to-end against LM Studio with
text-embedding-nomic-embed-text-v1.5 (768 dim): import, embed, vector search all pass. Existing embed tests still green.

Adds three env overrides so gbrain can run against any
OpenAI-compatible /v1/embeddings endpoint (LM Studio, Ollama,
vLLM, Together, self-hosted) instead of hardcoded OpenAI.

Environment variables:
  EMBEDDING_BASE_URL         custom endpoint (optional)
  EMBEDDING_API_KEY          api key (falls back to OPENAI_API_KEY)
  EMBEDDING_MODEL            model name (default: text-embedding-3-large)
  EMBEDDING_DIMENSIONS       vector dimension (default: 1536)
  EMBEDDING_SEND_DIMENSIONS  auto (default): sends dimensions only
                             when MODEL starts with text-embedding-3

Schema templates (pglite-schema.ts, schema-embedded.ts) now
interpolate EMBEDDING_MODEL and EMBEDDING_DIMENSIONS so the
pgvector column and config metadata match at gbrain init time.

Forces encoding_format: float in the request. The OpenAI SDK
defaults to base64 which LM Studio mis-decodes (returns 192
floats for a 768-dim nomic vector). float is spec-compliant
and all providers support it.

Verified end-to-end against LM Studio with
text-embedding-nomic-embed-text-v1.5 (768 dim): import,
embed, vector search all pass. Existing embed tests still
green.
@garrytan

garrytan commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks for this contribution — and apologies for the slow triage. We did a full pass over the entire PR backlog. gbrain has moved fast, and the maintainer's larger "cathedral" rewrites have superseded a big share of community PRs: the AI gateway + recipes + user_provided_models system replaced almost all individual provider PRs; #1805 fixed the whole Postgres module-singleton class; #1542 unified the type taxonomy; #1657 the retrieval path; #1802 the doctor; and so on.

We're closing this one in that cleanup — either the fix already landed on master, it duplicates another PR or merged change, or it's outside the current merge bar. Where a closed PR carried a genuinely valuable idea, we've recorded it in docs/designs/COMMUNITY_IDEAS.md so nothing good is lost (a few may graduate into TODOs).

Please don't read the close as a judgment of the work — thank you for contributing. If you believe the underlying issue is still live on the latest master, reopen with a quick note and we'll take another look. 🙏

@garrytan garrytan closed this Jun 8, 2026
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.

2 participants