From 8817e4d2db219d2b2861431208102df271eb2c3e Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Thu, 1 Jun 2023 11:17:34 +0800 Subject: [PATCH] feat: qa must pay --- public/docs/chatProblem.md | 1 - public/docs/intro.md | 1 - src/pages/kb/components/SelectFileModal.tsx | 2 +- src/pages/number/index.tsx | 2 +- src/service/events/generateQA.ts | 9 +++++---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/public/docs/chatProblem.md b/public/docs/chatProblem.md index 72d641ec8..a0582206c 100644 --- a/public/docs/chatProblem.md +++ b/public/docs/chatProblem.md @@ -14,7 +14,6 @@ 如果使用了自己的 Api Key,不会计费。可以在账号页,看到详细账单。 | 计费项 | 价格: 元/ 1K tokens(包含上下文)| | --- | --- | -| claude - 对话 | 免费 | | 知识库 - 索引 | 免费 | | chatgpt - 对话 | 0.025 | | gpt4 - 对话 | 0.5 | diff --git a/public/docs/intro.md b/public/docs/intro.md index 06268a577..d1253e29b 100644 --- a/public/docs/intro.md +++ b/public/docs/intro.md @@ -18,7 +18,6 @@ FastGpt 项目完全开源,可随意私有化部署,去除平台风险忧虑 如果使用了自己的 Api Key,不会计费。可以在账号页,看到详细账单。 | 计费项 | 价格: 元/ 1K tokens(包含上下文)| | --- | --- | -| claude - 对话 | 免费 | | 知识库 - 索引 | 免费 | | chatgpt - 对话 | 0.025 | | gpt4 - 对话 | 0.5 | diff --git a/src/pages/kb/components/SelectFileModal.tsx b/src/pages/kb/components/SelectFileModal.tsx index 268594837..9ec490eb9 100644 --- a/src/pages/kb/components/SelectFileModal.tsx +++ b/src/pages/kb/components/SelectFileModal.tsx @@ -67,7 +67,7 @@ const SelectFileModal = ({ chunks: [] }); const { openConfirm, ConfirmChild } = useConfirm({ - content: `确认导入该文件,需要一定时间进行拆解,该任务无法终止!如果余额不足,未完成的任务会被直接清除。一共 ${ + content: `确认导入该文件,需要一定时间进行拆解,该任务无法终止!QA 拆分仅能使用余额,如果余额不足,未完成的任务会被直接清除。一共 ${ splitRes.chunks.length } 组。${splitRes.tokens ? `大约 ${splitRes.tokens} 个tokens。` : ''}` }); diff --git a/src/pages/number/index.tsx b/src/pages/number/index.tsx index 19ba98bef..872f1af1e 100644 --- a/src/pages/number/index.tsx +++ b/src/pages/number/index.tsx @@ -136,7 +136,7 @@ const NumberSetting = () => { - 如果填写了自己的 openai 账号,将不会计费 + 如果填写了自己的 openai 账号,网页上 openai 模型对话不会计费。 diff --git a/src/service/events/generateQA.ts b/src/service/events/generateQA.ts index e76153e2d..1e377dd86 100644 --- a/src/service/events/generateQA.ts +++ b/src/service/events/generateQA.ts @@ -76,10 +76,11 @@ export async function generateQA(): Promise { const kbId = String(data.kbId); // 余额校验并获取 openapi Key - const { userOpenAiKey, systemAuthKey } = await getApiKey({ + const { systemAuthKey } = await getApiKey({ model: OpenAiChatEnum.GPT35, userId, - type: 'training' + type: 'training', + mustPay: true }); const startTime = Date.now(); @@ -89,7 +90,7 @@ export async function generateQA(): Promise { [data.q].map((text) => modelServiceToolMap[OpenAiChatEnum.GPT35] .chatCompletion({ - apiKey: userOpenAiKey || systemAuthKey, + apiKey: systemAuthKey, temperature: 0.8, messages: [ { @@ -114,7 +115,7 @@ A2: console.log(`split result length: `, result.length); // 计费 pushSplitDataBill({ - isPay: !userOpenAiKey && result.length > 0, + isPay: result.length > 0, userId: data.userId, type: BillTypeEnum.QA, textLen: responseMessages.map((item) => item.value).join('').length,