- 新的 Workbench:左边题目(可收起)+ AI 对话,右边预览 / 代码(可编辑),底部版本条; 挑战页和自由创作页都用它,原来的“手动提交”“历史对话”标签换成“粘贴外部代码”和“全部历史” - 不再每轮 AI 回复自动提交:学生点“交这一版”,可交多次,成绩仍取最高分;已交的版本不能重复点 - 手改代码、粘贴外部 AI 代码都存成版本(POST /prompt/versions,source 为 edit / manual), 在版本条和提示词链里标“手改”“外部 AI”;它们进入 AI 上下文,AI 在手改后的代码上继续改; 以前手动提交的回复正文为空时用代码补上;edit 的占位提问不参与提示词层级分类 - 互评从全屏弹窗改成对话里的卡片,打分前不显示作者,每个分数写明含义 - 编辑器代码按任务各存一份(useTaskCode),挑战页“清空”不再清掉教程的代码; 提交列表“复制到编辑器”对挑战写入该任务自己的代码 - 抽出 utils/code.ts(整理代码、拆分整页 HTML);删除 RandomRatingModal、ExternalAIPanel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* 用大模型给学生提示词标注布鲁姆认知层级(L1-L6)。
|
|
*
|
|
* bun scripts/classify-prompts.ts [--task-id N] [--force] [--dry-run]
|
|
*
|
|
* 默认只处理还没有层级的用户消息;--force 重新标注全部。
|
|
*/
|
|
import { parseArgs } from "node:util"
|
|
import { all } from "../src/db"
|
|
import { classifyMessage } from "../src/services/classifier"
|
|
import { llmConfigured } from "../src/services/llm"
|
|
|
|
const { values } = parseArgs({
|
|
options: {
|
|
"task-id": { type: "string" },
|
|
force: { type: "boolean", default: false },
|
|
"dry-run": { type: "boolean", default: false },
|
|
},
|
|
})
|
|
|
|
const where = ["m.role = 'user'", "m.source != 'edit'"]
|
|
const params: Record<string, unknown> = {}
|
|
if (values["task-id"]) {
|
|
where.push("c.task_id = $task_id")
|
|
params.task_id = Number(values["task-id"])
|
|
}
|
|
if (!values.force) where.push("m.prompt_level IS NULL")
|
|
|
|
const ids = all<{ id: number }>(
|
|
`SELECT m.id FROM prompt_message m JOIN prompt_conversation c ON c.id = m.conversation_id
|
|
WHERE ${where.join(" AND ")} ORDER BY m.created, m.id`,
|
|
params,
|
|
).map((r) => r.id)
|
|
|
|
console.log(`找到 ${ids.length} 条消息需要标注`)
|
|
if (values["dry-run"]) process.exit(0)
|
|
if (!llmConfigured()) {
|
|
console.error("没有配置 LLM_API_KEY")
|
|
process.exit(1)
|
|
}
|
|
|
|
for (const [i, id] of ids.entries()) {
|
|
const level = await classifyMessage(id)
|
|
console.log(`[${i + 1}/${ids.length}] msg#${id} → ${level ? `L${level}` : "(跳过)"}`)
|
|
await Bun.sleep(300)
|
|
}
|
|
console.log("完成")
|