Skip to content

Add optional Gemini embeddings support#58

Closed
k0nkupa wants to merge 2 commits into
garrytan:masterfrom
k0nkupa:gemini-embeddings-support
Closed

Add optional Gemini embeddings support#58
k0nkupa wants to merge 2 commits into
garrytan:masterfrom
k0nkupa:gemini-embeddings-support

Conversation

@k0nkupa

@k0nkupa k0nkupa commented Apr 12, 2026

Copy link
Copy Markdown

Summary

  • add optional Gemini embeddings support alongside the existing OpenAI path
  • keep embeddings at 1536 dimensions so existing GBrain vector schema remains compatible
  • document the new provider setup and add focused config tests

What changed

  • add embedding_provider, embedding_model, and gemini_api_key support in config loading
  • make the embedding service provider-aware (openai or gemini)
  • use Gemini batchEmbedContents with outputDimensionality: 1536
  • normalize Gemini vectors before storing them
  • let hybrid search run whenever any embedding provider is configured
  • persist the embedding model used on chunks during import/embed flows
  • add gbrain init --provider openai|gemini --key <api_key> support
  • update README/help text for Gemini usage
  • add targeted tests around provider selection/config overrides

Why this is safe

  • OpenAI remains the default behavior
  • no schema changes are required
  • Gemini is configured to emit 1536-dimensional embeddings, matching the current vector size

Verification

  • bun test test/embedding-provider.test.ts test/config.test.ts test/cli.test.ts
  • live local validation against a real Gemini API key:
    • direct embedding call returned 1536-dimensional vectors
    • embed --stale completed successfully on a local PGLite brain
    • semantic search worked after embedding

Notes

  • repo-wide TypeScript already has some unrelated pre-existing errors outside this change, so verification here is focused on the affected paths.

@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