Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 158 additions & 4 deletions packages/__tests__/cost/__snapshots__/registrySnapshots.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3578,6 +3578,102 @@ exports[`Registry Snapshots endpoint configurations snapshot 1`] = `
],
},
},
"minimax/minimax-m2.5": {
"minimax-m2.5-highspeed:minimax": {
"context": 204000,
"crossRegion": false,
"maxTokens": 8192,
"modelId": "MiniMax-M2.5-highspeed",
"parameters": [
"frequency_penalty",
"max_tokens",
"presence_penalty",
"response_format",
"stop",
"stream",
"temperature",
"tool_choice",
"tools",
"top_p",
],
"provider": "minimax",
"ptbEnabled": true,
"regions": [
"*",
],
},
"minimax-m2.5:minimax": {
"context": 204000,
"crossRegion": false,
"maxTokens": 8192,
"modelId": "MiniMax-M2.5",
"parameters": [
"frequency_penalty",
"max_tokens",
"presence_penalty",
"response_format",
"stop",
"stream",
"temperature",
"tool_choice",
"tools",
"top_p",
],
"provider": "minimax",
"ptbEnabled": true,
"regions": [
"*",
],
},
},
"minimax/minimax-m2.7": {
"minimax-m2.7-highspeed:minimax": {
"context": 1000000,
"crossRegion": false,
"maxTokens": 16384,
"modelId": "MiniMax-M2.7-highspeed",
"parameters": [
"frequency_penalty",
"max_tokens",
"presence_penalty",
"response_format",
"stop",
"stream",
"temperature",
"tool_choice",
"tools",
"top_p",
],
"provider": "minimax",
"ptbEnabled": true,
"regions": [
"*",
],
},
"minimax-m2.7:minimax": {
"context": 1000000,
"crossRegion": false,
"maxTokens": 16384,
"modelId": "MiniMax-M2.7",
"parameters": [
"frequency_penalty",
"max_tokens",
"presence_penalty",
"response_format",
"stop",
"stream",
"temperature",
"tool_choice",
"tools",
"top_p",
],
"provider": "minimax",
"ptbEnabled": true,
"regions": [
"*",
],
},
},
"mistral/mistral-large": {
"mistral-large-2411:mistral": {
"context": 128000,
Expand Down Expand Up @@ -7522,6 +7618,14 @@ exports[`Registry Snapshots model coverage snapshot 1`] = `
"openrouter",
"openrouter",
],
"minimax/minimax-m2.5": [
"minimax",
"minimax",
],
"minimax/minimax-m2.7": [
"minimax",
"minimax",
],
"mistral/mistral-large": [
"mistral",
],
Expand Down Expand Up @@ -9321,6 +9425,24 @@ exports[`Registry Snapshots pricing snapshot 1`] = `
},
],
},
"minimax/minimax-m2.5": {
"minimax": [
{
"input": 1e-7,
"output": 5.5e-7,
"threshold": 0,
},
],
},
"minimax/minimax-m2.7": {
"minimax": [
{
"input": 1e-7,
"output": 5.5e-7,
"threshold": 0,
},
],
},
"mistral/mistral-large": {
"mistral": [
{
Expand Down Expand Up @@ -10698,6 +10820,30 @@ exports[`Registry Snapshots verify registry state 1`] = `
"groq",
],
},
{
"model": "minimax-m2.5",
"providers": [
"minimax",
],
},
{
"model": "minimax-m2.5-highspeed",
"providers": [
"minimax",
],
},
{
"model": "minimax-m2.7",
"providers": [
"minimax",
],
},
{
"model": "minimax-m2.7-highspeed",
"providers": [
"minimax",
],
},
{
"model": "mistral-large-2411",
"providers": [
Expand Down Expand Up @@ -10897,6 +11043,10 @@ exports[`Registry Snapshots verify registry state 1`] = `
"modelCount": 55,
"provider": "helicone",
},
{
"modelCount": 4,
"provider": "minimax",
},
{
"modelCount": 1,
"provider": "mistral",
Expand Down Expand Up @@ -11017,6 +11167,10 @@ exports[`Registry Snapshots verify registry state 1`] = `
"llama-guard-4",
"llama-prompt-guard-2-22m",
"llama-prompt-guard-2-86m",
"minimax-m2.5",
"minimax-m2.5-highspeed",
"minimax-m2.7",
"minimax-m2.7-highspeed",
"mistral-large-2411",
"mistral-nemo",
"mistral-small",
Expand Down Expand Up @@ -11049,9 +11203,9 @@ exports[`Registry Snapshots verify registry state 1`] = `
"claude-3.5-haiku:anthropic:*",
],
"totalArchivedConfigs": 0,
"totalEndpoints": 329,
"totalModelProviderConfigs": 329,
"totalModelsWithPtb": 108,
"totalProviders": 21,
"totalEndpoints": 333,
"totalModelProviderConfigs": 333,
"totalModelsWithPtb": 112,
"totalProviders": 22,
}
`;
160 changes: 160 additions & 0 deletions packages/__tests__/cost/providers/minimax-integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import { describe, it, expect } from "@jest/globals";
import { registry } from "../../../cost/models/registry";
import {
buildEndpointUrl,
buildRequestBody,
parseModelString,
} from "../../../cost/models/provider-helpers";
import { getUsageProcessor } from "../../../cost/usage/getUsageProcessor";

describe("MiniMax integration", () => {
describe("model string parsing", () => {
it("should parse minimax-m2.7 without provider", () => {
const result = parseModelString("minimax-m2.7");
expect(result.data).toBeDefined();
expect(result.data?.modelName).toBe("minimax-m2.7");
expect(result.data?.provider).toBeUndefined();
});

it("should parse minimax-m2.7/minimax with provider", () => {
const result = parseModelString("minimax-m2.7/minimax");
expect(result.data).toBeDefined();
expect(result.data?.modelName).toBe("minimax-m2.7");
expect(result.data?.provider).toBe("minimax");
});

it("should parse minimax-m2.5-highspeed/minimax", () => {
const result = parseModelString("minimax-m2.5-highspeed/minimax");
expect(result.data).toBeDefined();
expect(result.data?.modelName).toBe("minimax-m2.5-highspeed");
expect(result.data?.provider).toBe("minimax");
});
});

describe("endpoint URL building", () => {
it("should build correct URL for minimax-m2.7", () => {
const configResult = registry.getModelProviderConfig(
"minimax-m2.7",
"minimax"
);
expect(configResult.data).toBeDefined();

const endpointResult = registry.buildEndpoint(configResult.data!, {});
expect(endpointResult.data).toBeDefined();

const urlResult = buildEndpointUrl(endpointResult.data!, {});
expect(urlResult.data).toBe(
"https://api.minimax.io/v1/chat/completions"
);
});
});

describe("usage processing", () => {
it("should process OpenAI-format usage for minimax", async () => {
const processor = getUsageProcessor("minimax");
expect(processor).not.toBeNull();

const mockResponse = {
id: "minimax-test-123",
object: "chat.completion",
created: Date.now(),
model: "MiniMax-M2.7",
choices: [
{
index: 0,
message: {
role: "assistant",
content: "Hello! How can I help you?",
},
finish_reason: "stop",
},
],
usage: {
prompt_tokens: 10,
completion_tokens: 8,
total_tokens: 18,
},
};

const result = await processor!.parse({
responseBody: JSON.stringify(mockResponse),
model: "MiniMax-M2.7",
isStream: false,
});
expect(result.data).toBeDefined();
expect(result.data?.input).toBe(10);
expect(result.data?.output).toBe(8);
});
});

describe("PTB endpoints", () => {
it("should return PTB endpoints for minimax-m2.7", () => {
const result = registry.getPtbEndpointsByProvider(
"minimax-m2.7",
"minimax"
);
expect(result.data).toBeDefined();
expect(result.data!.length).toBeGreaterThan(0);
expect(result.data![0].provider).toBe("minimax");
});

it("should return PTB endpoints for all MiniMax models", () => {
const models = [
"minimax-m2.7",
"minimax-m2.7-highspeed",
"minimax-m2.5",
"minimax-m2.5-highspeed",
];

for (const model of models) {
const result = registry.getPtbEndpointsByProvider(model, "minimax");
expect(result.data).toBeDefined();
expect(result.data!.length).toBeGreaterThan(0);
}
});
});

describe("full request flow", () => {
it("should build complete request for minimax-m2.7", async () => {
const configResult = registry.getModelProviderConfig(
"minimax-m2.7",
"minimax"
);
expect(configResult.data).toBeDefined();

const endpointResult = registry.buildEndpoint(configResult.data!, {});
expect(endpointResult.data).toBeDefined();

// Build URL
const urlResult = buildEndpointUrl(endpointResult.data!, {});
expect(urlResult.data).toBe(
"https://api.minimax.io/v1/chat/completions"
);

// Build request body
const mockBody = {
model: "minimax-m2.7",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is 1+1?" },
],
temperature: 0.7,
max_tokens: 100,
};

const bodyResult = await buildRequestBody(endpointResult.data!, {
parsedBody: mockBody,
bodyMapping: "OPENAI",
toAnthropic: (body: any) => body,
toChatCompletions: (body: any) => body,
});

expect(bodyResult.data).toBeDefined();
const parsed = JSON.parse(bodyResult.data!);
expect(parsed.model).toBe("MiniMax-M2.7");
expect(parsed.messages).toHaveLength(2);
expect(parsed.temperature).toBe(0.7);
expect(parsed.max_tokens).toBe(100);
});
});
});
Loading