fix(embedding): correct MiniMax (MiniMax CodePlan) adapter - #66
Merged
adoresever merged 1 commit intoAug 1, 2026
Merged
Conversation
The MiniMax row in README claimed baseURL=api.minimax.chat and 1024
dimensions, but the platform (called MiniMax here for legacy reasons;
real product is MiniMax CodePlan) actually serves embeddings from
api.minimaxi.com and returns 1536d vectors.
This change:
- Adds isMinimax(baseURL) detection and a MiniMax-specific request body
branch in createEmbedFn. MiniMax uses {texts:[...], type:"db"|"query"}
instead of OpenAI's {input:...}, returns data[0].vector instead of
data[0].embedding, and does not accept a dimensions field.
- Extends EmbedFn with an optional second 'mode' arg
("db" | "query") so recall callers can pass "query" while syncEmbed
and community summarization pass "db", matching MiniMax's separate
retrieval models.
- Updates all 4 call sites in src/recaller/recall.ts and
src/graph/community.ts to pass the appropriate mode.
- Corrects README.md / README_CN.md provider table
(baseURL, dimensions) and Universal embedding bullets to reflect the
real MiniMax embedding format.
Other OpenAI-compatible providers (OpenAI, DashScope, Jina, Ollama,
llama.cpp) are unaffected; their request body and response parsing
paths are unchanged.
There was a problem hiding this comment.
Pull request overview
This PR fixes the embedding adapter so MiniMax (MiniMax CodePlan) works correctly by using the provider-specific /embeddings request/response shape and by distinguishing between “db” vs “query” embedding modes, while keeping other OpenAI-compatible providers’ behavior unchanged.
Changes:
- Updated
createEmbedFnto detect MiniMax endpoints and switch to{ texts: [...], type }request bodies plusdata[0].vectorparsing, and extendedEmbedFnto accept an optional"db" | "query"mode. - Updated recall and community summarization call sites to pass
"query"for search-time embeddings and"db"for stored vectors. - Updated README/README_CN provider docs (MiniMax baseURL + dimensions + format exception note).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/engine/embed.ts | Adds MiniMax detection + request/response branching and introduces EmbedMode in the embedding function signature. |
| src/recaller/recall.ts | Passes "query" for recall searches and "db" for background embedding sync. |
| src/graph/community.ts | Uses "db" mode when generating/storing community summary embeddings. |
| README.md | Corrects MiniMax provider docs (baseURL/dimensions) and documents the non-OpenAI request shape. |
| README_CN.md | Same as README.md, for Chinese documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+58
to
+60
| function isMinimax(baseURL: string): boolean { | ||
| return /minimaxi\.com|minimax\.chat|minimax\.io/i.test(baseURL); | ||
| } |
Comment on lines
+14
to
+17
| * 兼容 OpenAI、阿里云 DashScope、MiniMax(MiniMax CodePlan)、Jina、Ollama、llama.cpp 等。 | ||
| * | ||
| * MiniMax(MiniMax) 是特例: | ||
| * - 端点走 anthropic 协议但 embeddings 用 OpenAI 风格变体 |
Contributor
|
你好,这个repo似乎不再被维护,可以向https://github.com/TriDefender/graph-memory 提 |
adoresever
approved these changes
Aug 1, 2026
adoresever
left a comment
Owner
There was a problem hiding this comment.
修复已采纳并合并:MiniMax CodePlan 的适配方向正确。合并时把域名判断收紧为精确主机名匹配,并补充请求/响应适配测试,避免相似域名误判。感谢贡献。
TriDefender
added a commit
to TriDefender/graph-memory
that referenced
this pull request
Aug 2, 2026
Accepted PR 66 adoresever#66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the embedding adapter so that users running the MiniMax CodePlan OAuth service (the platform referred to as "MiniMax" in the README — the alias predates this PR and is left intact for backward compatibility) can actually use it.
What's wrong today
baseURL=https://api.minimax.chat/v1anddimensions=1024for MiniMax. The reachable endpoint ishttps://api.minimaxi.com/v1andembo-01returns 1536-d vectors.{"input": "..."}and readsdata[0].embedding. MiniMax's/embeddingsexpects{"texts": [...], "type": "db"|"query"}and returnsdata[0].vector. So every call fails withmissing required parameter expr_path=textsor returns an empty embedding.What this PR changes
src/engine/embed.tsisMinimax(baseURL)detection (matchesminimaxi.com,minimax.chat,minimax.io).{model, texts:[input], type}instead of{model, input}, and omitsdimensions(MiniMax rejects it).data[0].vectorfor MiniMax,data[0].embeddingfor everything else.EmbedFnto(text: string, mode?: "db" | "query") => Promise<number[]>. MiniMax routes the two modes through different retrieval models, so callers need to be explicit.src/recaller/recall.ts—recallPrecise/recallGeneralizedpass"query",syncEmbedpasses"db".src/graph/community.ts— community summarization passes"db".README.md/README_CN.mdbaseURL=api.minimaxi.com,dimensions=1536, label clarified asMiniMax (MiniMax CodePlan).Backward compatibility
data[0].embeddingparsing, samedimensionshandling. Their existing embeddings keep working.modeargument onEmbedFnis optional and defaults to"db", so any external code that constructs a customEmbedFnkeeps compiling.Verification
EmbedFncall sites all pass the new mode (verified by grepping forthis.embed(/embedFn().api.minimaxi.com). Before the patch the embed probe fails withmissing required parameter expr_path=texts; after the patch recall reportsvector search readyand 1536-d vectors are stored and used for vector search + community summaries.Notes for the maintainer
MiniMax (MiniMax CodePlan)so the official product name is now discoverable from the docs. Happy to rename wholesale in a follow-up if you'd prefer.vitest run. The change is small (one new function plus a branch inbuildBody) and the four call-site updates are mechanical, but I can add a unit test forcreateEmbedFnif you want.