update
This commit is contained in:
@@ -169,11 +169,17 @@ export function createGenerateRouter(apiKey: string | undefined): Hono {
|
||||
|
||||
const entries = rawEntries
|
||||
.map((entry, index) => {
|
||||
const e = entry as { index?: unknown; title?: unknown; charCount?: unknown }
|
||||
const e = entry as {
|
||||
index?: unknown
|
||||
title?: unknown
|
||||
charCount?: unknown
|
||||
depth?: unknown
|
||||
}
|
||||
const title = typeof e?.title === 'string' ? e.title.trim() : ''
|
||||
const entryIndex = typeof e?.index === 'number' ? e.index : index
|
||||
const charCount = typeof e?.charCount === 'number' ? e.charCount : 0
|
||||
return { index: entryIndex, title, charCount }
|
||||
const depth = typeof e?.depth === 'number' && e.depth > 0 ? e.depth : 0
|
||||
return { index: entryIndex, title, charCount, depth }
|
||||
})
|
||||
.filter((entry) => entry.title !== '')
|
||||
|
||||
@@ -186,7 +192,10 @@ export function createGenerateRouter(apiKey: string | undefined): Hono {
|
||||
}
|
||||
|
||||
const tocText = entries
|
||||
.map((entry) => `${entry.index}\t${entry.title}\t约${entry.charCount}字`)
|
||||
.map(
|
||||
(entry) =>
|
||||
`${entry.index}\t${' '.repeat(entry.depth)}${entry.title}\t约${entry.charCount}字`,
|
||||
)
|
||||
.join('\n')
|
||||
|
||||
let response: Response
|
||||
@@ -203,7 +212,7 @@ export function createGenerateRouter(apiKey: string | undefined): Hono {
|
||||
{
|
||||
role: 'system',
|
||||
content:
|
||||
'你是教学设计专家。下面是一本教材的目录,每行为「序号<TAB>标题<TAB>正文体量」。' +
|
||||
'你是教学设计专家。下面是一本教材的目录,每行为「序号<TAB>标题<TAB>正文体量」,标题前的缩进表示层级(章 → 节 → 小节),同一上级标题下的条目应优先归到相邻课时。' +
|
||||
'请据此把全书划分为一系列单课时课题:难度由浅入深、覆盖全部目录条目,体量小的相邻条目可合并为一课时,体量大的条目可拆成多课时。' +
|
||||
'每个课题对应一个或多个目录条目(用其序号表示)。' +
|
||||
'仅输出 JSON,不要解释、不要代码块围栏,形如:' +
|
||||
|
||||
Reference in New Issue
Block a user