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