xiongzhu 2 yıl önce
ebeveyn
işleme
672301f4b1

+ 8 - 21
.vscode/launch.json

@@ -1,24 +1,11 @@
 {
-    // Use IntelliSense to learn about possible attributes.
-    // Hover to view descriptions of existing attributes.
-    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
-    "version": "0.2.0",
     "configurations": [
-    {
-        "name": "Launch Program",
-        "program": "${workspaceFolder}/pdf.mjs",
-        "request": "launch",
-        "skipFiles": [
-            "<node_internals>/**"
-        ],
-        "type": "node"
-    },
-      {
-        "type": "node",
-        "request": "attach",
-        "name": "Attach NestJS WS",
-        "port": 9229,
-        "restart": true
-      }
+        {
+            "type": "node-terminal",
+            "name": "运行脚本: start:debug",
+            "request": "launch",
+            "command": "yarn start:debug",
+            "cwd": "${workspaceFolder}"
+        }
     ]
-  }
+}

BIN
res/custom-reference.docx


+ 16 - 1
src/paper/paper-gen/abstract.ts

@@ -24,7 +24,22 @@ ${desc}
 ${abstract}`)
     ])
 
-    return `# 摘要\n\n${abstract}\n\n# Abstract\n\n${translated}`
+    return `::: {custom-style="Abstract Title"}
+摘要
+:::
+
+::: {custom-style="Abstract"}
+${abstract}
+:::
+
+::: {custom-style="Abstract Title"}
+Abstract
+:::
+
+::: {custom-style="Abstract"}
+${translated}
+:::
+`
 }
 
 export async function createAbstract(tools: LLMTools, title, desc) {

+ 11 - 2
src/paper/paper-gen/general.ts

@@ -69,7 +69,9 @@ ${chapters2md(chapters)}
 不要擅作主张输出你对该内容的总结或者介绍等其他文字,不需要出现介绍下一章或其他承上启下的文字。
 你要严格遵守我的指令,按照我的指定的章节和小节完成论文的写作。
 请直接开始写作,不要对内容作任何解释。`
-        paper.write('\n\n# ' + chapter.title)
+        paper.write(
+            `\n\n# 第${NumberToChinese.convertNumber(i + 1, { removeLeadingOne: i + 1 >= 10 })}章 ${chapter.title}`
+        )
         if (chapter.children && chapter.children.length) {
             // for (let j = 0; j < chapter.children.length; j++) {
             //     const section = chapter.children[j]
@@ -106,7 +108,14 @@ ${chapters2md(chapters)}
         } else {
             let prompt = `第${i + 1}章: # ${chapter.title} (请注意只需要编写这一章的内容)`
             if (chapter.title.includes('参考文献')) {
-                prompt += `(请给出一些文献来支持我的论点和方法,请给出文献的标题,作者,年份,摘要和关键词)`
+                prompt = `几种主要参考文献的格式为:
+专(译)著:[序号]作者.书名(译者).出版地:出版者,出版年,起止页码
+连续出版物:[序号]作者.文献题名.刊名.出版年,卷号(期号):起止页码
+论文集:[序号]作者. 文献题名.编者.文集名.出版地:出版者,出版年,起止页码
+学位论文:[序号]作者. 文献题名.[博士(或硕士)学位论文].授予单位,授予年
+技术标准:[序号]发布单位.技术标准代号.技术标准名称.出版地:出版者,出版日期
+
+请按照以上的格式提供一些参考文献来支持我的论点和方法`
             }
             let { content } = await llm.call([new SystemMessage(sysPrompt), new HumanMessage(prompt)])
             content = content.replace(new RegExp(`#.*${chapter.title}.*\n`), '')

+ 8 - 1
src/paper/paper-gen/upload.ts

@@ -80,7 +80,14 @@ export async function uploadDoc(title, content) {
     })
 
     const { execa } = await (eval('import("execa")') as Promise<typeof import('execa')>)
-    const p = execa('pandoc', ['-f', 'markdown', '-t', 'docx'])
+    const p = execa('pandoc', [
+        '-f',
+        'markdown',
+        '-t',
+        'docx',
+        '--reference-doc',
+        path.join(__dirname, '../../../res/custom-reference.docx')
+    ])
     Readable.from(content).pipe(p.stdin)
     const err = new WritableStreamBuffer()
     p.pipeStdout(stream)