-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy pathminimax-integration.test.ts
More file actions
112 lines (100 loc) · 3.26 KB
/
minimax-integration.test.ts
File metadata and controls
112 lines (100 loc) · 3.26 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
import { OpenAI } from 'openai';
// Mock @clack/prompts to prevent process.exit calls
jest.mock('@clack/prompts', () => ({
intro: jest.fn(),
outro: jest.fn()
}));
/**
* Integration tests for MiniMax engine.
* These tests verify the MiniMax API works correctly via OpenAI-compatible SDK.
* This mirrors the exact behavior of MiniMaxEngine which extends OpenAiEngine.
*
* Run with: MINIMAX_API_KEY=<key> npm run test -- test/unit/minimax-integration.test.ts
*/
const MINIMAX_API_KEY = process.env.MINIMAX_API_KEY;
const describeIntegration = MINIMAX_API_KEY ? describe : describe.skip;
describeIntegration('MiniMax Integration (requires MINIMAX_API_KEY)', () => {
let client: OpenAI;
beforeAll(() => {
client = new OpenAI({
apiKey: MINIMAX_API_KEY!,
baseURL: 'https://api.minimax.io/v1'
});
});
it('should generate a commit message with M2.7', async () => {
const completion = await client.chat.completions.create({
model: 'MiniMax-M2.7',
messages: [
{
role: 'system',
content:
'You are an expert at writing concise, meaningful git commit messages. Generate a conventional commit message for the provided code diff. Output only the commit message, nothing else.'
},
{
role: 'user',
content: `diff --git a/src/utils.ts b/src/utils.ts
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -10,6 +10,10 @@ export function formatDate(date: Date): string {
return date.toISOString();
}
+export function formatCurrency(amount: number, currency: string = 'USD'): string {
+ return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount);
+}
+
export function capitalize(str: string): string {`
}
],
temperature: 0.01,
top_p: 0.1,
max_tokens: 500
});
const content = completion.choices[0].message?.content;
expect(content).toBeDefined();
expect(typeof content).toBe('string');
expect(content!.length).toBeGreaterThan(0);
}, 30000);
it('should generate commit message with M2.5-highspeed', async () => {
const completion = await client.chat.completions.create({
model: 'MiniMax-M2.5-highspeed',
messages: [
{
role: 'system',
content:
'You are an expert at writing concise git commit messages. Generate a conventional commit message. Output only the commit message.'
},
{
role: 'user',
content: `diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
# My Project
A simple project.
+
+## Installation`
}
],
temperature: 0.01,
top_p: 0.1,
max_tokens: 500
});
const content = completion.choices[0].message?.content;
expect(content).toBeDefined();
expect(typeof content).toBe('string');
expect(content!.length).toBeGreaterThan(0);
}, 30000);
it('should handle authentication error with invalid API key', async () => {
const badClient = new OpenAI({
apiKey: 'invalid-api-key',
baseURL: 'https://api.minimax.io/v1'
});
await expect(
badClient.chat.completions.create({
model: 'MiniMax-M2.7',
messages: [{ role: 'user', content: 'test' }],
max_tokens: 10
})
).rejects.toThrow();
}, 30000);
});