|
|
@@ -1,30 +1,30 @@
|
|
|
const axios = require('axios');
|
|
|
|
|
|
-const BASE_URL = 'http://localhost:3000';
|
|
|
-
|
|
|
-async function testAIModels() {
|
|
|
- console.log('=== 测试 AI 模型接口 ===\n');
|
|
|
-
|
|
|
+async function testAI() {
|
|
|
try {
|
|
|
- console.log('1️⃣ 测试获取 AI 模型列表...');
|
|
|
- const result = await axios.get(`${BASE_URL}/api/ai/models`);
|
|
|
- console.log('✅ AI 模型列表:', JSON.stringify(result.data, null, 2));
|
|
|
-
|
|
|
- console.log('\n2️⃣ 测试 AI 文本生成...');
|
|
|
- const generate = await axios.post(`${BASE_URL}/api/ai/generate`, {
|
|
|
- prompt: '写一首关于春天的短诗',
|
|
|
- model: 'tongyi-xiaomi-analysis-pro'
|
|
|
+ console.log('🧪 测试 AI 接口...');
|
|
|
+
|
|
|
+ const response = await axios.post('https://api.minimaxi.chat/v1/text/chatcompletion_v2', {
|
|
|
+ model: 'MiniMax-M2.7',
|
|
|
+ messages: [
|
|
|
+ { role: 'user', content: '你好,请回复OK' }
|
|
|
+ ],
|
|
|
+ max_tokens: 10
|
|
|
}, {
|
|
|
- timeout: 60000
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${process.env.MINIMAX_API_KEY}`,
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ timeout: 30000
|
|
|
});
|
|
|
- console.log('✅ AI 生成成功:', JSON.stringify(generate.data, null, 2));
|
|
|
|
|
|
+ console.log('✅ AI 接口正常');
|
|
|
+ console.log('响应:', response.data.choices?.[0]?.message?.content);
|
|
|
} catch (error) {
|
|
|
- console.error('❌ 测试失败:', error.message);
|
|
|
- if (error.response) {
|
|
|
- console.error('📋 错误响应:', JSON.stringify(error.response.data, null, 2));
|
|
|
- }
|
|
|
+ console.error('❌ AI 接口失败:');
|
|
|
+ console.error('状态码:', error.response?.status);
|
|
|
+ console.error('错误信息:', error.response?.data || error.message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-testAIModels();
|
|
|
+testAI();
|