| 123456789101112131415161718192021222324252627282930 |
- const axios = require('axios');
- const BASE_URL = 'http://localhost:3000';
- async function testAIModels() {
- console.log('=== 测试 AI 模型接口 ===\n');
- 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'
- }, {
- timeout: 60000
- });
- console.log('✅ AI 生成成功:', JSON.stringify(generate.data, null, 2));
- } catch (error) {
- console.error('❌ 测试失败:', error.message);
- if (error.response) {
- console.error('📋 错误响应:', JSON.stringify(error.response.data, null, 2));
- }
- }
- }
- testAIModels();
|