|
@@ -86,13 +86,18 @@ ${chapters2md(chapters)}
|
|
|
let prompt
|
|
let prompt
|
|
|
if (section.children?.length) {
|
|
if (section.children?.length) {
|
|
|
prompt = `${chapters2md(section.children, [i + 1, j + 1])}
|
|
prompt = `${chapters2md(section.children, [i + 1, j + 1])}
|
|
|
-请按照以上结构编写第${i + 1}章: # ${chapter.title}
|
|
|
|
|
-## ${i + 1}.${j + 1} ${section.title} (请注意只需要编写这一小节的内容):`
|
|
|
|
|
|
|
+请按照以上结构编写第${i + 1}章${chapter.title}的${i + 1}.${j + 1}小节(请注意只需要编写这一小节的内容)
|
|
|
|
|
+## ${i + 1}.${j + 1} ${section.title} :`
|
|
|
} else {
|
|
} else {
|
|
|
- prompt = `第${i + 1}章: # ${chapter.title}
|
|
|
|
|
-## ${i + 1}.${j + 1} ${section.title} (请注意只需要编写这一小节的内容):`
|
|
|
|
|
|
|
+ prompt = `请编写第${i + 1}章${chapter.title}的${i + 1}.${
|
|
|
|
|
+ j + 1
|
|
|
|
|
+ }小节(请注意只需要编写这一小节的内容)
|
|
|
|
|
+## ${i + 1}.${j + 1} ${section.title}:`
|
|
|
}
|
|
}
|
|
|
- const { content } = await llm.call([new SystemMessage(sysPrompt), new HumanMessage(prompt)])
|
|
|
|
|
|
|
+ let { content } = await llm.call([new SystemMessage(sysPrompt), new HumanMessage(prompt)])
|
|
|
|
|
+ content = content
|
|
|
|
|
+ .replace(new RegExp(`#.*${chapter.title}.*\n`), '')
|
|
|
|
|
+ .replace(new RegExp(`#.*${section.title}.*\n`), '')
|
|
|
return `## ${i + 1}.${j + 1} ${section.title}\n\n` + content
|
|
return `## ${i + 1}.${j + 1} ${section.title}\n\n` + content
|
|
|
})
|
|
})
|
|
|
)
|
|
)
|
|
@@ -103,7 +108,8 @@ ${chapters2md(chapters)}
|
|
|
if (chapter.title.includes('参考文献')) {
|
|
if (chapter.title.includes('参考文献')) {
|
|
|
prompt += `(请给出一些文献来支持我的论点和方法,请给出文献的标题,作者,年份,摘要和关键词)`
|
|
prompt += `(请给出一些文献来支持我的论点和方法,请给出文献的标题,作者,年份,摘要和关键词)`
|
|
|
}
|
|
}
|
|
|
- const { content } = await llm.call([new SystemMessage(sysPrompt), new HumanMessage(prompt)])
|
|
|
|
|
|
|
+ let { content } = await llm.call([new SystemMessage(sysPrompt), new HumanMessage(prompt)])
|
|
|
|
|
+ content = content.replace(new RegExp(`#.*${chapter.title}.*\n`), '')
|
|
|
// if (!content.trim().split('\n')[0].includes(chapter.title)) {
|
|
// if (!content.trim().split('\n')[0].includes(chapter.title)) {
|
|
|
// paper.write(`\n\n# ${chapter.title}`)
|
|
// paper.write(`\n\n# ${chapter.title}`)
|
|
|
// }
|
|
// }
|