Skip to content

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

Open
asperty567 wants to merge 1 commit intogarrytan:masterfrom
asperty567:link/local-embeddings
Open

feat(embedding): pluggable OpenAI-compatible embedding provider#178
asperty567 wants to merge 1 commit intogarrytan: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.
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