update
This commit is contained in:
@@ -90,13 +90,18 @@ export function createGenerateRouter(apiKey: string | undefined): Hono {
|
||||
})
|
||||
|
||||
app.post('/outline', async (c) => {
|
||||
const body = (await c.req.json().catch(() => null)) as { theme?: unknown } | null
|
||||
const body = (await c.req.json().catch(() => null)) as
|
||||
| { theme?: unknown; count?: unknown }
|
||||
| null
|
||||
const theme = body?.theme
|
||||
|
||||
if (typeof theme !== 'string' || theme.trim() === '') {
|
||||
return c.json({ error: '请提供课程主题。' }, 400)
|
||||
}
|
||||
|
||||
const rawCount = typeof body?.count === 'number' ? body.count : 18
|
||||
const count = Math.min(50, Math.max(1, Math.round(rawCount)))
|
||||
|
||||
if (!apiKey) {
|
||||
return c.json({ error: '未配置 DEEPSEEK_API_KEY。' }, 500)
|
||||
}
|
||||
@@ -115,7 +120,7 @@ export function createGenerateRouter(apiKey: string | undefined): Hono {
|
||||
{
|
||||
role: 'system',
|
||||
content:
|
||||
'你是教学设计专家。根据用户提供的课程主题,生成一份完整的课时大纲标题列表,共约18条。' +
|
||||
`你是教学设计专家。根据用户提供的课程主题,生成一份完整的课时大纲标题列表,共约${count}条。` +
|
||||
'每个标题格式为"项目名——课时任务",一行一个,不加序号、不加任何说明,直接输出标题列表。',
|
||||
},
|
||||
{ role: 'user', content: `课程主题:${theme.trim()}` },
|
||||
|
||||
Reference in New Issue
Block a user