feat: qa must pay

This commit is contained in:
archer
2023-06-01 11:17:34 +08:00
parent c9ee6fabe4
commit 8817e4d2db
5 changed files with 7 additions and 8 deletions

View File

@@ -14,7 +14,6 @@
如果使用了自己的 Api Key不会计费。可以在账号页看到详细账单。 如果使用了自己的 Api Key不会计费。可以在账号页看到详细账单。
| 计费项 | 价格: 元/ 1K tokens包含上下文| | 计费项 | 价格: 元/ 1K tokens包含上下文|
| --- | --- | | --- | --- |
| claude - 对话 | 免费 |
| 知识库 - 索引 | 免费 | | 知识库 - 索引 | 免费 |
| chatgpt - 对话 | 0.025 | | chatgpt - 对话 | 0.025 |
| gpt4 - 对话 | 0.5 | | gpt4 - 对话 | 0.5 |

View File

@@ -18,7 +18,6 @@ FastGpt 项目完全开源,可随意私有化部署,去除平台风险忧虑
如果使用了自己的 Api Key不会计费。可以在账号页看到详细账单。 如果使用了自己的 Api Key不会计费。可以在账号页看到详细账单。
| 计费项 | 价格: 元/ 1K tokens包含上下文| | 计费项 | 价格: 元/ 1K tokens包含上下文|
| --- | --- | | --- | --- |
| claude - 对话 | 免费 |
| 知识库 - 索引 | 免费 | | 知识库 - 索引 | 免费 |
| chatgpt - 对话 | 0.025 | | chatgpt - 对话 | 0.025 |
| gpt4 - 对话 | 0.5 | | gpt4 - 对话 | 0.5 |

View File

@@ -67,7 +67,7 @@ const SelectFileModal = ({
chunks: [] chunks: []
}); });
const { openConfirm, ConfirmChild } = useConfirm({ const { openConfirm, ConfirmChild } = useConfirm({
content: `确认导入该文件,需要一定时间进行拆解,该任务无法终止!如果余额不足,未完成的任务会被直接清除。一共 ${ content: `确认导入该文件,需要一定时间进行拆解,该任务无法终止!QA 拆分仅能使用余额,如果余额不足,未完成的任务会被直接清除。一共 ${
splitRes.chunks.length splitRes.chunks.length
} 组。${splitRes.tokens ? `大约 ${splitRes.tokens} 个tokens。` : ''}` } 组。${splitRes.tokens ? `大约 ${splitRes.tokens} 个tokens。` : ''}`
}); });

View File

@@ -136,7 +136,7 @@ const NumberSetting = () => {
</Button> </Button>
</Flex> </Flex>
<Box fontSize={'xs'} color={'blackAlpha.500'}> <Box fontSize={'xs'} color={'blackAlpha.500'}>
openai openai openai
</Box> </Box>
</Box> </Box>
<Flex mt={6} alignItems={'center'}> <Flex mt={6} alignItems={'center'}>

View File

@@ -76,10 +76,11 @@ export async function generateQA(): Promise<any> {
const kbId = String(data.kbId); const kbId = String(data.kbId);
// 余额校验并获取 openapi Key // 余额校验并获取 openapi Key
const { userOpenAiKey, systemAuthKey } = await getApiKey({ const { systemAuthKey } = await getApiKey({
model: OpenAiChatEnum.GPT35, model: OpenAiChatEnum.GPT35,
userId, userId,
type: 'training' type: 'training',
mustPay: true
}); });
const startTime = Date.now(); const startTime = Date.now();
@@ -89,7 +90,7 @@ export async function generateQA(): Promise<any> {
[data.q].map((text) => [data.q].map((text) =>
modelServiceToolMap[OpenAiChatEnum.GPT35] modelServiceToolMap[OpenAiChatEnum.GPT35]
.chatCompletion({ .chatCompletion({
apiKey: userOpenAiKey || systemAuthKey, apiKey: systemAuthKey,
temperature: 0.8, temperature: 0.8,
messages: [ messages: [
{ {
@@ -114,7 +115,7 @@ A2:
console.log(`split result length: `, result.length); console.log(`split result length: `, result.length);
// 计费 // 计费
pushSplitDataBill({ pushSplitDataBill({
isPay: !userOpenAiKey && result.length > 0, isPay: result.length > 0,
userId: data.userId, userId: data.userId,
type: BillTypeEnum.QA, type: BillTypeEnum.QA,
textLen: responseMessages.map((item) => item.value).join('').length, textLen: responseMessages.map((item) => item.value).join('').length,