feat: add Copilot embedding provider#691
Conversation
Adds native Copilot embedding provider for GitHub Copilot/Blackbird Metis embeddings. Calls GitHub /embeddings endpoint directly with the Copilot request/response shape; not OpenAI-compatible. - New recipe: src/core/ai/recipes/copilot.ts with metis-1024-I16-Binary - New implementation kind: 'native-copilot' in types.ts - gateway.ts: native-copilot branches in instantiateEmbedding/Expansion/Chat (embedding does real fetch; chat+expansion throw clear errors since this provider is embedding-only) - embedSubBatch short-circuits when model is a Copilot model, bypassing Vercel AI SDK and threading abortSignal into native fetch Replaces garrytan#450. Built on current master (v0.36) instead of v0.22 legacy path. Auth: GBRAIN_COPILOT_TOKEN, COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN, or ~/.copilot/config.json (Copilot CLI login). Config: export GBRAIN_EMBEDDING_MODEL=copilot:metis-1024-I16-Binary export GBRAIN_EMBEDDING_DIMENSIONS=1024
e0d584e to
5cc285e
Compare
Silences ai.gateway warning that the copilot embedding touchpoint had no batch cap declared. 8192 matches zhipu/dashscope/azure-openai which all use the same OpenAI-style /embeddings shape.
|
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. 🙏 |
|
Verified on master HEAD What's actually on master
The "user_provided_models system" mentioned in the close note is What this PR adds
I forward-ported this to v0.42.36 locally to confirm the patch shape still applies cleanly (recipes/types.ts/gateway.ts integration points are unchanged from v0.36 → v0.42; only Why this mattersGitHub Copilot's embedding endpoint is the only zero-config embedding option for users who already pay for Copilot — no separate API key, no extra service, just This is +192/-0, fully isolated, tests included. Would appreciate a re-look. 🙏 |
Adds native Copilot embedding provider for GitHub Copilot/Blackbird Metis
embeddings. Calls GitHub's /embeddings endpoint directly with the Copilot
request/response shape (`{ inputs, model }` → `{ embeddings: [{ embedding }] }`),
bypassing the Vercel AI SDK because the shape is not OpenAI-compatible.
Wires up across all four touchpoints required for `isAvailable('embedding')`
to return true on v0.42:
1. types.ts: add 'native-copilot' to the Implementation union
2. recipes/copilot.ts: new recipe with metis-1024-I16-Binary model (1024d)
3. recipes/index.ts: register copilot in ALL[]
4. gateway.ts: marker-based routing in instantiateEmbedding +
embedSubBatch short-circuit + clear errors in expansion/chat
Auth chain: GBRAIN_COPILOT_TOKEN, COPILOT_GITHUB_TOKEN, GH_TOKEN,
GITHUB_TOKEN, then ~/.copilot/config.json (Copilot CLI login).
Vectors are L2-normalized before return for pgvector cosine distance.
Dim mismatch is caught immediately with a migrate hint. abortSignal is
threaded into native fetch.
Config:
export GBRAIN_EMBEDDING_MODEL=copilot:metis-1024-I16-Binary
export GBRAIN_EMBEDDING_DIMENSIONS=1024
Replaces PR garrytan#691 (closed in batch cleanup); rebased on top of v0.42.36
master with the new gateway.ts retry/timeout/abortSignal infrastructure
plus max_batch_tokens declaration on the recipe (v0.32 batch budget
validation hard-fails recipes without it on first import).
|
Rebased on top of master Push: Verified locallyThe full What changed during the v0.36 → v0.42 forward-port
Architecture summaryBypasses the Vercel AI SDK because GitHub's Diff is +213/-0 across 5 files. Would appreciate a re-look. 🙏 |
|
Continued in #1998 (rebase couldn't reopen this PR per GitHub's force-push policy). |
Summary
copilotembedding provider for GitHub Copilot / Blackbird Metis embeddings.GBRAIN_EMBEDDING_MODEL=copilot:metis-1024-I16-Binarywith 1024-dim vectors./embeddingsendpoint directly using the Copilot request/response shape instead of pretending it is OpenAI-compatible.Why
This replaces stale PR #450, which targeted the old v0.22 embedding path. Current
masteruses the v0.27+ AI gateway / recipe provider system, so this PR is intentionally much smaller and built on latestmaster.Test plan
bun run typecheckbun test test/ai/copilot-provider.test.tsbun test test/ai/copilot-provider.test.ts test/schema-bootstrap-coverage.test.ts test/operations-allow-list.test.ts test/pages-soft-delete.test.tsgbrain providers listshowscopilot ✓ ready1024Replaces #450.
Need help on this PR? Tag
@codesmithwith what you need.