perf: bill logs

This commit is contained in:
archer
2023-03-27 13:58:57 +08:00
parent 9280a21d12
commit 5249297cb1
6 changed files with 160 additions and 152 deletions

View File

@@ -148,13 +148,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const promptsContent = formatPrompts.map((item) => item.content).join('');
// 只有使用平台的 key 才计费
!userApiKey &&
pushChatBill({
modelName: model.service.modelName,
userId,
chatId,
text: promptsContent + responseContent
});
pushChatBill({
isPay: !userApiKey,
modelName: model.service.modelName,
userId,
chatId,
text: promptsContent + responseContent
});
} catch (err: any) {
if (step === 1) {
// 直接结束流

View File

@@ -149,13 +149,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
stream.destroy();
// 只有使用平台的 key 才计费
!userApiKey &&
pushChatBill({
modelName: model.service.modelName,
userId,
chatId,
text: promptText + responseContent
});
pushChatBill({
isPay: !userApiKey,
modelName: model.service.modelName,
userId,
chatId,
text: promptText + responseContent
});
} catch (err: any) {
// console.log(err?.response);
if (step === 1) {