mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(minimax): Bổ sung MiniMax-M3 + cập nhật Quota Tracker coding/CN
Squash-merge PR #1631 (decolua/9router) — chỉ lấy file code + test, bỏ docs. - feat(minimax): add MiniMax-M3 to intl + cn provider models (targetFormat claude) - feat(minimax): add MiniMax-M3 pricing entry - fix(minimax): translate Claude body khi content=null (M3 thinking-only) - fix(minimax): hiển thị quota M-series bucket "general"/"MiniMax-M*" + percent-only - test: minimax usage / model registration / pricing Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Claude
Cursor
parent
cce8a50cac
commit
41f94ce8c8
@@ -113,4 +113,127 @@ describe("MiniMax usage", () => {
|
||||
expect(usage.quotas["Music 2.6 (5h)"].used).toBe(5);
|
||||
expect(usage.quotas["Image 01 (5h)"].used).toBe(2);
|
||||
});
|
||||
|
||||
it("includes M-series percent-only buckets that have no count totals", async () => {
|
||||
proxyAwareFetch.mockResolvedValueOnce(
|
||||
usageResponse([
|
||||
{
|
||||
model_name: "general",
|
||||
current_interval_remaining_percent: 70,
|
||||
current_weekly_remaining_percent: 64,
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
const usage = await getUsageForProvider({
|
||||
provider: "minimax",
|
||||
apiKey: "test-key",
|
||||
});
|
||||
|
||||
expect(usage.message).toBeUndefined();
|
||||
expect(usage.quotas["M-series (5h)"]).toMatchObject({
|
||||
used: 30,
|
||||
total: 100,
|
||||
remaining: 70,
|
||||
remainingPercentage: 70,
|
||||
});
|
||||
expect(usage.quotas["M-series (7d)"]).toMatchObject({
|
||||
used: 36,
|
||||
total: 100,
|
||||
remaining: 64,
|
||||
remainingPercentage: 64,
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes M-series percent-only buckets on the coding_plan (countMeansRemaining) endpoint too", async () => {
|
||||
proxyAwareFetch.mockResolvedValueOnce(
|
||||
usageResponse([
|
||||
{
|
||||
model_name: "general",
|
||||
current_interval_remaining_percent: 80,
|
||||
current_weekly_remaining_percent: 95,
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
const usage = await getUsageForProvider({
|
||||
provider: "minimax-cn",
|
||||
apiKey: "test-key",
|
||||
});
|
||||
|
||||
expect(usage.message).toBeUndefined();
|
||||
expect(usage.quotas["M-series (5h)"]).toMatchObject({
|
||||
used: 20,
|
||||
total: 100,
|
||||
remaining: 80,
|
||||
remainingPercentage: 80,
|
||||
});
|
||||
expect(usage.quotas["M-series (7d)"]).toMatchObject({
|
||||
used: 5,
|
||||
total: 100,
|
||||
remaining: 95,
|
||||
remainingPercentage: 95,
|
||||
});
|
||||
});
|
||||
|
||||
it("renders the M3-era MiniMax-M* wildcard as a friendly series label", async () => {
|
||||
proxyAwareFetch.mockResolvedValueOnce(
|
||||
usageResponse([
|
||||
{
|
||||
modelName: "MiniMax-M*",
|
||||
currentIntervalTotalCount: 4000,
|
||||
currentIntervalUsageCount: 3200,
|
||||
currentWeeklyTotalCount: 24000,
|
||||
currentWeeklyUsageCount: 18000,
|
||||
remainsTime: 1000,
|
||||
weeklyRemainsTime: 2000,
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
const usage = await getUsageForProvider({
|
||||
provider: "minimax-cn",
|
||||
apiKey: "test-key",
|
||||
});
|
||||
|
||||
expect(usage.message).toBeUndefined();
|
||||
expect(Object.keys(usage.quotas)).toEqual([
|
||||
"M-series (5h)",
|
||||
"M-series (7d)",
|
||||
]);
|
||||
expect(usage.quotas["M-series (5h)"]).toMatchObject({
|
||||
used: 800,
|
||||
total: 4000,
|
||||
remaining: 3200,
|
||||
});
|
||||
expect(usage.quotas["M-series (7d)"]).toMatchObject({
|
||||
used: 6000,
|
||||
total: 24000,
|
||||
remaining: 18000,
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the upstream-provided remaining percent when counts are also present", async () => {
|
||||
proxyAwareFetch.mockResolvedValueOnce(
|
||||
usageResponse([
|
||||
{
|
||||
model_name: "general",
|
||||
current_interval_total_count: 4000,
|
||||
current_interval_usage_count: 100,
|
||||
current_interval_remaining_percent: 84,
|
||||
current_weekly_total_count: 24000,
|
||||
current_weekly_usage_count: 500,
|
||||
current_weekly_remaining_percent: 42,
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
const usage = await getUsageForProvider({
|
||||
provider: "minimax",
|
||||
apiKey: "test-key",
|
||||
});
|
||||
|
||||
expect(usage.quotas["M-series (5h)"].remainingPercentage).toBe(84);
|
||||
expect(usage.quotas["M-series (7d)"].remainingPercentage).toBe(42);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Unit tests verifying MiniMax-M3 is registered as a first-class
|
||||
* built-in model for both the `minimax` (international) and
|
||||
* `minimax-cn` (China) providers, with `targetFormat: "claude"`.
|
||||
*
|
||||
* Run: cd tests && NODE_PATH=/tmp/node_modules /tmp/node_modules/.bin/vitest run tests/unit/provider-models-minimax-m3.test.js --reporter=verbose
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { PROVIDER_MODELS, getModelsByProviderId } from "../../open-sse/config/providerModels.js";
|
||||
|
||||
describe("MiniMax-M3 model registration", () => {
|
||||
it("includes MiniMax-M3 in PROVIDER_MODELS.minimax", () => {
|
||||
const models = PROVIDER_MODELS.minimax || [];
|
||||
const m3 = models.find((m) => m.id === "MiniMax-M3");
|
||||
expect(m3).toBeDefined();
|
||||
expect(m3).toMatchObject({
|
||||
id: "MiniMax-M3",
|
||||
name: "MiniMax M3",
|
||||
targetFormat: "claude",
|
||||
});
|
||||
});
|
||||
|
||||
it("includes MiniMax-M3 in PROVIDER_MODELS['minimax-cn']", () => {
|
||||
const models = PROVIDER_MODELS["minimax-cn"] || [];
|
||||
const m3 = models.find((m) => m.id === "MiniMax-M3");
|
||||
expect(m3).toBeDefined();
|
||||
expect(m3).toMatchObject({
|
||||
id: "MiniMax-M3",
|
||||
name: "MiniMax M3",
|
||||
targetFormat: "claude",
|
||||
});
|
||||
});
|
||||
|
||||
it("exposes MiniMax-M3 through getModelsByProviderId for both provider IDs", () => {
|
||||
const intlModels = getModelsByProviderId("minimax");
|
||||
const cnModels = getModelsByProviderId("minimax-cn");
|
||||
|
||||
expect(intlModels.some((m) => m.id === "MiniMax-M3")).toBe(true);
|
||||
expect(cnModels.some((m) => m.id === "MiniMax-M3")).toBe(true);
|
||||
});
|
||||
|
||||
it("does not regress the existing M2.7 / M2.5 / M2.1 entries", () => {
|
||||
const intlIds = (PROVIDER_MODELS.minimax || []).map((m) => m.id);
|
||||
const cnIds = (PROVIDER_MODELS["minimax-cn"] || []).map((m) => m.id);
|
||||
|
||||
for (const id of ["MiniMax-M2.7", "MiniMax-M2.5", "MiniMax-M2.1"]) {
|
||||
expect(intlIds).toContain(id);
|
||||
expect(cnIds).toContain(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { MODEL_PRICING } from "../../src/shared/constants/pricing.js";
|
||||
|
||||
describe("MiniMax-M3 pricing", () => {
|
||||
it("includes MiniMax-M3 in MODEL_PRICING", () => {
|
||||
expect(MODEL_PRICING["MiniMax-M3"]).toBeDefined();
|
||||
});
|
||||
|
||||
it("MiniMax-M3 pricing has numeric shape (input, output, cached)", () => {
|
||||
const pricing = MODEL_PRICING["MiniMax-M3"];
|
||||
expect(pricing).toMatchObject({
|
||||
input: expect.any(Number),
|
||||
output: expect.any(Number),
|
||||
cached: expect.any(Number),
|
||||
});
|
||||
});
|
||||
|
||||
it("MiniMax-M3 input price matches the design spec (0.30)", () => {
|
||||
expect(MODEL_PRICING["MiniMax-M3"].input).toBe(0.30);
|
||||
});
|
||||
|
||||
it("MiniMax-M3 output price matches the design spec (1.20)", () => {
|
||||
expect(MODEL_PRICING["MiniMax-M3"].output).toBe(1.20);
|
||||
});
|
||||
|
||||
it("MiniMax-M3 cached price matches the design spec (0.06)", () => {
|
||||
expect(MODEL_PRICING["MiniMax-M3"].cached).toBe(0.06);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user