Skip to content

feat: pluggable embedding provider — E5 adapter for self-hosted embeddings#150

Open
SZabolotnii wants to merge 2 commits intogarrytan:masterfrom
SZabolotnii:feat/e5-embedding-adapter
Open

feat: pluggable embedding provider — E5 adapter for self-hosted embeddings#150
SZabolotnii wants to merge 2 commits intogarrytan:masterfrom
SZabolotnii:feat/e5-embedding-adapter

Conversation

@SZabolotnii
Copy link
Copy Markdown

Summary

  • Pluggable embedding providers: GBRAIN_EMBEDDING_PROVIDER=e5|openai selects between self-hosted E5 and OpenAI. OpenAI remains default.
  • E5 HTTP adapter (embedding-e5.ts): talks to self-hosted intfloat/multilingual-e5-small (or compatible) endpoint with auto-dimension detection, retry, batch splitting.
  • Extracted OpenAI provider (embedding-openai.ts): same behavior, clean separation.
  • Dynamic vector dimensions: schema creation substitutes vector(384) for E5 or vector(1536) for OpenAI across PGLite and Postgres engines.
  • 12 unit tests: E5 adapter (fetch mock, batching, truncation, dimension detection), OpenAI exports, provider router, schema substitution.
  • Deployed and verified on VPS with Ayona's E5 container — gbrain init creates vector(384) schema, doctor reports health_score=90.

Env vars

Variable Default Description
GBRAIN_EMBEDDING_PROVIDER openai e5 or openai
GBRAIN_E5_URL http://embeddings-e5:8000/embed E5 endpoint URL
GBRAIN_E5_BATCH_SIZE 16 Texts per E5 request

Test plan

  • bun test — 858 pass, 0 fail
  • test/embedding.test.ts — 12 tests covering all providers
  • VPS deployment verified (E5 384d, doctor healthy)
  • E2E with real Postgres+pgvector (requires DATABASE_URL)

🤖 Generated with Claude Code

SZabolotnii and others added 2 commits April 16, 2026 12:18
…dings

Add support for self-hosted E5 embedding models (intfloat/multilingual-e5-small)
as an alternative to OpenAI. Enables zero-cost embeddings using existing
infrastructure (e.g., Ayona's E5 container on VPS).

- New provider router in embedding.ts (GBRAIN_EMBEDDING_PROVIDER=e5|openai)
- E5 HTTP adapter (embedding-e5.ts) with auto-dimension detection, retry, batch
- Extracted OpenAI provider into embedding-openai.ts (no behavior change)
- Dynamic vector(N) in schema — 384d for E5, 1536d for OpenAI
- Schema dimension substitution in db.ts, postgres-engine.ts, pglite-engine.ts

Deployed and verified on VPS: gbrain init with E5 creates vector(384) schema,
doctor reports health_score=90, all checks OK.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 unit tests for E5 adapter (fetch mock, batching, truncation, dimension
detection), OpenAI adapter exports, provider router, and schema dimension
substitution. CHANGELOG v0.10.2 entry. CLAUDE.md updated with new files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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