xiongzhu 2 лет назад
Родитель
Сommit
4861d03ef1

+ 2 - 0
src/paper/paper-gen/arch.ts

@@ -3,6 +3,7 @@ import { StructuredOutputParser } from 'langchain/output_parsers'
 import { z } from 'zod'
 import { uploadUml } from './upload'
 import { LLMTools } from './types'
+import { createLLM } from './llm'
 
 export async function _createArch(tools: LLMTools, title, desc) {
     const { llm, usage, conversation } = tools
@@ -52,6 +53,7 @@ rectangle 租客管理
 }
 
 export async function createArch(tools: LLMTools, title, desc) {
+    tools = createLLM('gpt-4')
     const pRetry = (await eval("import('p-retry')")).default
     return await pRetry(() => _createArch(tools, title, desc), { retries: 5 })
 }

+ 7 - 3
src/paper/paper-gen/er.ts

@@ -3,6 +3,7 @@ import { StructuredOutputParser } from 'langchain/output_parsers'
 import { z } from 'zod'
 import { uploadUml } from './upload'
 import { LLMTools } from './types'
+import { createLLM } from './llm'
 
 async function genErNames(tools: LLMTools, title, desc) {
     const { llm, usage, conversation } = tools
@@ -14,15 +15,17 @@ async function genErNames(tools: LLMTools, title, desc) {
         )
     )
 
-    const res = await llm.call([
-        new HumanMessage(`${scheme.getFormatInstructions()}
+    const res = await llm.call(
+        [
+            new HumanMessage(`${scheme.getFormatInstructions()}
 ------
 你是一个计算机专业擅长写毕业论文的专家,你的任务是帮我的毕业设计撰写一篇论文
 我的毕业设计项目是${title}
 这个项目包含以下功能:
 ${desc}
 现在我们需要开始为这个系统设计数据库,首先我们分析一下系统中有哪些实体,我们需要绘制以下五个主要ER图:`)
-    ])
+        ],
+    )
     return await scheme.parse(res.content)
 }
 
@@ -68,6 +71,7 @@ price
 }
 
 export async function createER(tools: LLMTools, title, desc) {
+    tools = createLLM('gpt-4')
     const pRetry = (await eval("import('p-retry')")).default
     const list = await pRetry(() => genErNames(tools, title, desc), { retries: 5 })
     return await Promise.all(list.map((item) => pRetry(() => plotER(tools, title, desc, item.title), { retries: 5 })))

+ 2 - 0
src/paper/paper-gen/flow.ts

@@ -3,6 +3,7 @@ import { StructuredOutputParser } from 'langchain/output_parsers'
 import { z } from 'zod'
 import { uploadUml } from './upload'
 import { LLMTools } from './types'
+import { createLLM } from './llm'
 
 async function genFlowNames(tools: LLMTools, title, desc) {
     const { llm, usage, conversation } = tools
@@ -65,6 +66,7 @@ stop
 }
 
 export async function createFlow(tools: LLMTools, title, desc) {
+    tools = createLLM('gpt-4')
     const pRetry = (await eval("import('p-retry')")).default
     const list = await pRetry(() => genFlowNames(tools, title, desc), { retries: 5 })
     return await Promise.all(list.map((item) => pRetry(() => plotFlow(tools, title, desc, item.title), { retries: 5 })))

+ 5 - 3
src/paper/paper-gen/index.ts

@@ -102,9 +102,11 @@ ${chapters[i].sections.map((i) => i.title).join('\n')}\n`
 ![总体结构图](${arch.url})
 
 以及以下用例图:
-${useCases.map((i) => {
-    return `- ![${i.name}用例图](${i.url})`
-})}
+${useCases
+    .map((i) => {
+        return `- ![${i.name}用例图](${i.url})`
+    })
+    .join('\n')}
 
 请你帮我完成第${j + 1}小节: ${chapters[i].sections[j].title}的内容,请确保附上我提供的总体结构图和用例图`
                 }

+ 2 - 0
src/paper/paper-gen/table.ts

@@ -3,6 +3,7 @@ import { StructuredOutputParser } from 'langchain/output_parsers'
 import { z } from 'zod'
 import pRetry from 'p-retry'
 import { LLMTools } from './types'
+import { createLLM } from './llm'
 
 async function listTables(tools: LLMTools, title, desc) {
     const { llm, usage, conversation } = tools
@@ -39,6 +40,7 @@ ${list.map((i) => `- ${i}`).join('\n')}
 }
 
 export async function createTable(tools: LLMTools, title, desc) {
+    tools = createLLM('gpt-4')
     const pRetry = (await eval("import('p-retry')")).default
     const list = await pRetry(() => listTables(tools, title, desc), { retries: 5 })
 

+ 1 - 0
src/paper/paper-gen/useCase.ts

@@ -46,6 +46,7 @@ ${roles.map((e, i) => `${i + 1}. ${e.roleName}: ${e.roleDesc}`).join('\n')}
 }
 
 export async function createUseCase(tools: LLMTools, title, desc) {
+    tools = createLLM('gpt-4')
     const pRetry = (await eval("import('p-retry')")).default
     const roles = await pRetry(() => genRoles(tools, title, desc), {
         retries: 5,