智教助手平台:完整初始化
- 前端:Vue3 + TS + Element Plus,24 个页面路由(课件/组题/教案/动画/思维导图/作文批改/命题/课堂/资源/社区等) - 后端:FastAPI + SQLAlchemy + SQLite,17 个路由模块,AI 服务层含降级模板 - AI:glm-5.x 推理模型已禁用思维链,确保输出真实内容 - 修复:ai_service 两处请求体注入 enable_thinking/thinking disabled - 测试账号:13900999999 / test1234
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>API调试工具</title>
|
||||
<style>
|
||||
body{font-family:monospace;padding:20px;background:#1e1e1e;color:#d4d4d4;font-size:13px;}
|
||||
button{padding:8px 16px;margin:4px;border:none;border-radius:4px;cursor:pointer;font-size:13px;}
|
||||
.btn-login{background:#4F46E5;color:#fff;}
|
||||
.btn-gen{background:#10B981;color:#fff;}
|
||||
#log{background:#000;padding:16px;border-radius:8px;white-space:pre-wrap;max-height:600px;overflow:auto;margin-top:16px;line-height:1.6;}
|
||||
.ok{color:#4ADE80;} .err{color:#F87171;} .info{color:#60A5FA;} .warn{color:#FBBF24;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>AI课件生成 - 调试工具</h2>
|
||||
<button class="btn-login" onclick="doLogin()">1. 登录获取Token</button>
|
||||
<button class="btn-gen" onclick="doGenerate()">2. 调用AI生成课件</button>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
let token = '';
|
||||
const log = document.getElementById('log');
|
||||
|
||||
function addLog(msg, cls='info') {
|
||||
log.innerHTML += `<span class="${cls}">${msg}</span>\n`;
|
||||
log.scrollTop = log.scrollHeight;
|
||||
}
|
||||
|
||||
async function doLogin() {
|
||||
log.innerHTML = '';
|
||||
addLog('正在登录...', 'info');
|
||||
try {
|
||||
const r = await fetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({phone: '13800001111', password: 'Test1234'})
|
||||
});
|
||||
const data = await r.json();
|
||||
if (data.access_token) {
|
||||
token = data.access_token;
|
||||
addLog(`登录成功! Token: ${token.substring(0,30)}...`, 'ok');
|
||||
} else {
|
||||
addLog(`登录失败: ${JSON.stringify(data)}`, 'err');
|
||||
}
|
||||
} catch(e) {
|
||||
addLog(`登录异常: ${e.message}`, 'err');
|
||||
}
|
||||
}
|
||||
|
||||
async function doGenerate() {
|
||||
if (!token) { addLog('请先登录!', 'warn'); return; }
|
||||
addLog('正在调用AI生成课件(可能需要1-3分钟)...', 'info');
|
||||
try {
|
||||
const r = await fetch('/api/coursewares/ai-generate', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token},
|
||||
body: JSON.stringify({prompt:'生成一元一次方程课件',subject:'数学',grade:'初一',page_count:3})
|
||||
});
|
||||
addLog(`HTTP状态: ${r.status} ${r.statusText}`, r.ok ? 'ok' : 'err');
|
||||
const text = await r.text();
|
||||
addLog(`响应长度: ${text.length} 字符`, 'info');
|
||||
|
||||
// Try parse
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch(e) {
|
||||
addLog(`JSON解析失败: ${e.message}`, 'err');
|
||||
addLog(`前500字符: ${text.substring(0,500)}`, 'warn');
|
||||
return;
|
||||
}
|
||||
|
||||
addLog(`顶层keys: ${Object.keys(data).join(', ')}`, 'info');
|
||||
addLog(`success: ${data.success}`, 'info');
|
||||
|
||||
if (data.data) {
|
||||
addLog(`data.data类型: ${typeof data.data}`, 'info');
|
||||
if (typeof data.data === 'object') {
|
||||
addLog(`data.data keys: ${Object.keys(data.data).join(', ')}`, 'info');
|
||||
const pages = data.data.pages;
|
||||
addLog(`pages: ${pages ? pages.length : 'undefined/null'}`, pages?.length ? 'ok' : 'err');
|
||||
if (pages && pages.length > 0) {
|
||||
for (let i = 0; i < pages.length; i++) {
|
||||
const p = pages[i];
|
||||
const content = p.content || '';
|
||||
addLog(` Page ${i+1}: type=${p.type} title=${p.title} content_len=${content.length} has_html=${content.includes('<div')}`, 'info');
|
||||
}
|
||||
addLog(`\nPage 1 content前200字符:\n${pages[0].content.substring(0,200)}`, 'ok');
|
||||
} else {
|
||||
addLog(`\n⚠️ pages为空或undefined!`, 'err');
|
||||
addLog(`完整data.data: ${JSON.stringify(data.data).substring(0,1000)}`, 'warn');
|
||||
}
|
||||
} else {
|
||||
addLog(`⚠️ data.data不是对象: ${typeof data.data}`, 'err');
|
||||
addLog(`data.data值: ${String(data.data).substring(0,500)}`, 'warn');
|
||||
}
|
||||
} else {
|
||||
addLog(`⚠️ 没有data字段!`, 'err');
|
||||
addLog(`完整响应: ${text.substring(0,1000)}`, 'warn');
|
||||
}
|
||||
} catch(e) {
|
||||
addLog(`请求异常: ${e.message}`, 'err');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user