-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathminimax.test.ts
More file actions
142 lines (124 loc) · 5.06 KB
/
minimax.test.ts
File metadata and controls
142 lines (124 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { describe, it, expect, beforeEach, afterEach } from 'bun:test'
import {
MINIMAX_M2_7_CONFIG,
MINIMAX_M2_7_HIGHSPEED_CONFIG,
ALL_MODEL_CONFIGS,
} from '../configs.js'
import {
getAPIProvider,
isFirstPartyAnthropicBaseUrl,
} from '../providers.js'
describe('MiniMax provider', () => {
let originalEnv: Record<string, string | undefined>
beforeEach(() => {
originalEnv = {
CLAUDE_CODE_USE_BEDROCK: process.env.CLAUDE_CODE_USE_BEDROCK,
CLAUDE_CODE_USE_VERTEX: process.env.CLAUDE_CODE_USE_VERTEX,
CLAUDE_CODE_USE_FOUNDRY: process.env.CLAUDE_CODE_USE_FOUNDRY,
CLAUDE_CODE_USE_MINIMAX: process.env.CLAUDE_CODE_USE_MINIMAX,
}
delete process.env.CLAUDE_CODE_USE_BEDROCK
delete process.env.CLAUDE_CODE_USE_VERTEX
delete process.env.CLAUDE_CODE_USE_FOUNDRY
delete process.env.CLAUDE_CODE_USE_MINIMAX
})
afterEach(() => {
for (const [key, value] of Object.entries(originalEnv)) {
if (value === undefined) {
delete process.env[key]
} else {
process.env[key] = value
}
}
})
describe('getAPIProvider', () => {
it('returns minimax when CLAUDE_CODE_USE_MINIMAX is set', () => {
process.env.CLAUDE_CODE_USE_MINIMAX = '1'
expect(getAPIProvider()).toBe('minimax')
})
it('returns firstParty when CLAUDE_CODE_USE_MINIMAX is not set', () => {
expect(getAPIProvider()).toBe('firstParty')
})
it('bedrock takes priority over minimax', () => {
process.env.CLAUDE_CODE_USE_MINIMAX = '1'
process.env.CLAUDE_CODE_USE_BEDROCK = '1'
expect(getAPIProvider()).toBe('bedrock')
})
it('vertex takes priority over minimax', () => {
process.env.CLAUDE_CODE_USE_MINIMAX = '1'
process.env.CLAUDE_CODE_USE_VERTEX = '1'
expect(getAPIProvider()).toBe('vertex')
})
})
describe('isFirstPartyAnthropicBaseUrl', () => {
it('returns false when provider is minimax', () => {
process.env.CLAUDE_CODE_USE_MINIMAX = '1'
expect(isFirstPartyAnthropicBaseUrl()).toBe(false)
})
it('returns true for firstParty without custom base URL', () => {
delete process.env.ANTHROPIC_BASE_URL
expect(isFirstPartyAnthropicBaseUrl()).toBe(true)
})
})
describe('MiniMax model configs', () => {
it('MINIMAX_M2_7_CONFIG has correct model IDs', () => {
expect(MINIMAX_M2_7_CONFIG.minimax).toBe('MiniMax-M2.7')
expect(MINIMAX_M2_7_CONFIG.firstParty).toBe('MiniMax-M2.7')
})
it('MINIMAX_M2_7_HIGHSPEED_CONFIG has correct model IDs', () => {
expect(MINIMAX_M2_7_HIGHSPEED_CONFIG.minimax).toBe('MiniMax-M2.7-highspeed')
expect(MINIMAX_M2_7_HIGHSPEED_CONFIG.firstParty).toBe('MiniMax-M2.7-highspeed')
})
it('MiniMax configs are registered in ALL_MODEL_CONFIGS', () => {
expect('minimaxM27' in ALL_MODEL_CONFIGS).toBe(true)
expect('minimaxM27hs' in ALL_MODEL_CONFIGS).toBe(true)
})
it('minimaxM27 resolves to MiniMax-M2.7 under minimax provider', () => {
const config = ALL_MODEL_CONFIGS.minimaxM27
const resolved = config['minimax'] ?? config.firstParty
expect(resolved).toBe('MiniMax-M2.7')
})
it('minimaxM27hs resolves to MiniMax-M2.7-highspeed under minimax provider', () => {
const config = ALL_MODEL_CONFIGS.minimaxM27hs
const resolved = config['minimax'] ?? config.firstParty
expect(resolved).toBe('MiniMax-M2.7-highspeed')
})
it('Claude model configs fall back to firstParty under minimax provider', () => {
const haiku35 = ALL_MODEL_CONFIGS.haiku35
// minimax key not present for Claude models — falls back to firstParty
const resolved = haiku35['minimax'] ?? haiku35.firstParty
expect(resolved).toBe('claude-3-5-haiku-20241022')
})
})
describe('MiniMax API constraints', () => {
it('default base URL uses overseas api.minimax.io (not api.minimax.chat)', () => {
const defaultBaseUrl = 'https://api.minimax.io/anthropic'
expect(defaultBaseUrl).toContain('api.minimax.io')
expect(defaultBaseUrl).not.toContain('api.minimax.chat')
})
it('filters unsupported parameters for Anthropic-compatible API', () => {
const UNSUPPORTED_PARAMS = new Set(['top_k', 'stop_sequences', 'service_tier'])
const input: Record<string, unknown> = {
model: 'MiniMax-M2.7',
messages: [{ role: 'user', content: 'hi' }],
top_k: 40,
stop_sequences: ['END'],
temperature: 1.0,
}
const filtered = Object.fromEntries(
Object.entries(input).filter(([k]) => !UNSUPPORTED_PARAMS.has(k)),
)
expect('top_k' in filtered).toBe(false)
expect('stop_sequences' in filtered).toBe(false)
expect('temperature' in filtered).toBe(true)
expect('model' in filtered).toBe(true)
})
it('validates temperature range (0.0, 1.0] — 0 is invalid for MiniMax', () => {
const isValidTemperature = (t: number) => t > 0 && t <= 1.0
expect(isValidTemperature(1.0)).toBe(true)
expect(isValidTemperature(0.5)).toBe(true)
expect(isValidTemperature(0.0)).toBe(false)
expect(isValidTemperature(1.1)).toBe(false)
})
})
})