mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 22:05:04 +00:00
fix(models): support minimax-portal coding plan vlm routing for image tool (openclaw#33953)
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tars90percent <252094836+tars90percent@users.noreply.github.com>
This commit is contained in:
@@ -45,3 +45,14 @@ describe("minimaxUnderstandImage apiKey normalization", () => {
|
||||
await runNormalizationCase("minimax-\u0417\u2502test-key");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isMinimaxVlmModel", () => {
|
||||
it("only matches the canonical MiniMax VLM model id", async () => {
|
||||
const { isMinimaxVlmModel } = await import("./minimax-vlm.js");
|
||||
|
||||
expect(isMinimaxVlmModel("minimax", "MiniMax-VL-01")).toBe(true);
|
||||
expect(isMinimaxVlmModel("minimax-portal", "MiniMax-VL-01")).toBe(true);
|
||||
expect(isMinimaxVlmModel("minimax-portal", "custom-vision")).toBe(false);
|
||||
expect(isMinimaxVlmModel("openai", "MiniMax-VL-01")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,14 @@ type MinimaxBaseResp = {
|
||||
status_msg?: string;
|
||||
};
|
||||
|
||||
export function isMinimaxVlmProvider(provider: string): boolean {
|
||||
return provider === "minimax" || provider === "minimax-portal";
|
||||
}
|
||||
|
||||
export function isMinimaxVlmModel(provider: string, modelId: string): boolean {
|
||||
return isMinimaxVlmProvider(provider) && modelId.trim() === "MiniMax-VL-01";
|
||||
}
|
||||
|
||||
function coerceApiHost(params: {
|
||||
apiHost?: string;
|
||||
modelBaseUrl?: string;
|
||||
|
||||
@@ -71,10 +71,9 @@ describe("MiniMax implicit provider (#15275)", () => {
|
||||
"minimax-portal:default": {
|
||||
type: "oauth",
|
||||
provider: "minimax-portal",
|
||||
oauth: {
|
||||
access: "token",
|
||||
expires: Date.now() + 60_000,
|
||||
},
|
||||
access: "token",
|
||||
refresh: "refresh-token",
|
||||
expires: Date.now() + 60_000,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -87,6 +86,18 @@ describe("MiniMax implicit provider (#15275)", () => {
|
||||
const providers = await resolveImplicitProviders({ agentDir });
|
||||
expect(providers?.["minimax-portal"]?.authHeader).toBe(true);
|
||||
});
|
||||
|
||||
it("should include minimax portal provider when MINIMAX_OAUTH_TOKEN is configured", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
await withEnvAsync({ MINIMAX_OAUTH_TOKEN: "portal-token" }, async () => {
|
||||
const providers = await resolveImplicitProviders({ agentDir });
|
||||
expect(providers?.["minimax-portal"]).toBeDefined();
|
||||
expect(providers?.["minimax-portal"]?.authHeader).toBe(true);
|
||||
expect(providers?.["minimax-portal"]?.models?.some((m) => m.id === "MiniMax-VL-01")).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("vLLM provider", () => {
|
||||
|
||||
@@ -771,6 +771,12 @@ function buildMinimaxPortalProvider(): ProviderConfig {
|
||||
api: "anthropic-messages",
|
||||
authHeader: true,
|
||||
models: [
|
||||
buildMinimaxModel({
|
||||
id: MINIMAX_DEFAULT_VISION_MODEL_ID,
|
||||
name: "MiniMax VL 01",
|
||||
reasoning: false,
|
||||
input: ["text", "image"],
|
||||
}),
|
||||
buildMinimaxTextModel({
|
||||
id: MINIMAX_DEFAULT_MODEL_ID,
|
||||
name: "MiniMax M2.5",
|
||||
@@ -1116,8 +1122,9 @@ export async function resolveImplicitProviders(params: {
|
||||
providers.minimax = { ...buildMinimaxProvider(), apiKey: minimaxKey };
|
||||
}
|
||||
|
||||
const minimaxPortalEnvKey = resolveEnvApiKeyVarName("minimax-portal");
|
||||
const minimaxOauthProfile = listProfilesForProvider(authStore, "minimax-portal");
|
||||
if (minimaxOauthProfile.length > 0) {
|
||||
if (minimaxPortalEnvKey || minimaxOauthProfile.length > 0) {
|
||||
providers["minimax-portal"] = {
|
||||
...buildMinimaxPortalProvider(),
|
||||
apiKey: MINIMAX_OAUTH_MARKER,
|
||||
|
||||
@@ -273,6 +273,32 @@ describe("image tool implicit imageModel config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("pairs minimax-portal primary with MiniMax-VL-01 (and fallbacks) when auth exists", async () => {
|
||||
await withTempAgentDir(async (agentDir) => {
|
||||
await writeAuthProfiles(agentDir, {
|
||||
version: 1,
|
||||
profiles: {
|
||||
"minimax-portal:default": {
|
||||
type: "oauth",
|
||||
provider: "minimax-portal",
|
||||
access: "oauth-test",
|
||||
refresh: "refresh-test",
|
||||
expires: Date.now() + 60_000,
|
||||
},
|
||||
},
|
||||
});
|
||||
vi.stubEnv("OPENAI_API_KEY", "openai-test");
|
||||
vi.stubEnv("ANTHROPIC_API_KEY", "anthropic-test");
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: { defaults: { model: { primary: "minimax-portal/MiniMax-M2.5" } } },
|
||||
};
|
||||
expect(resolveImageModelConfigForTool({ cfg, agentDir })).toEqual(
|
||||
createDefaultImageFallbackExpectation("minimax-portal/MiniMax-VL-01"),
|
||||
);
|
||||
expect(createImageTool({ config: cfg, agentDir })).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it("pairs zai primary with glm-4.6v (and fallbacks) when auth exists", async () => {
|
||||
await withTempAgentDir(async (agentDir) => {
|
||||
vi.stubEnv("ZAI_API_KEY", "zai-test");
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Type } from "@sinclair/typebox";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveUserPath } from "../../utils.js";
|
||||
import { loadWebMedia } from "../../web/media.js";
|
||||
import { minimaxUnderstandImage } from "../minimax-vlm.js";
|
||||
import { isMinimaxVlmModel, isMinimaxVlmProvider, minimaxUnderstandImage } from "../minimax-vlm.js";
|
||||
import {
|
||||
coerceImageAssistantText,
|
||||
coerceImageModelConfig,
|
||||
@@ -110,8 +110,8 @@ export function resolveImageModelConfigForTool(params: {
|
||||
let preferred: string | null = null;
|
||||
|
||||
// MiniMax users: always try the canonical vision model first when auth exists.
|
||||
if (primary.provider === "minimax" && providerOk) {
|
||||
preferred = "minimax/MiniMax-VL-01";
|
||||
if (isMinimaxVlmProvider(primary.provider) && providerOk) {
|
||||
preferred = `${primary.provider}/MiniMax-VL-01`;
|
||||
} else if (providerOk && providerVisionFromConfig) {
|
||||
preferred = providerVisionFromConfig;
|
||||
} else if (primary.provider === "zai" && providerOk) {
|
||||
@@ -229,7 +229,7 @@ async function runImagePrompt(params: {
|
||||
});
|
||||
|
||||
// MiniMax VLM only supports a single image; use the first one.
|
||||
if (model.provider === "minimax") {
|
||||
if (isMinimaxVlmModel(model.provider, model.id)) {
|
||||
const first = params.images[0];
|
||||
const imageDataUrl = `data:${first.mimeType};base64,${first.base64}`;
|
||||
const text = await minimaxUnderstandImage({
|
||||
|
||||
Reference in New Issue
Block a user