From ab959cb1e94697eb3431b1e433e43e25fa4799a3 Mon Sep 17 00:00:00 2001 From: vastxie Date: Sun, 28 Jan 2024 00:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BAtoken=E8=AE=A1=E8=B4=B9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/modules/chatgpt/chatgpt.service.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dist/modules/chatgpt/chatgpt.service.js b/dist/modules/chatgpt/chatgpt.service.js index 5d07933..c5298cc 100644 --- a/dist/modules/chatgpt/chatgpt.service.js +++ b/dist/modules/chatgpt/chatgpt.service.js @@ -321,9 +321,8 @@ let ChatgptService = class ChatgptService { onProgress: null, }); } - let prompt_tokens = response.prompt_tokens || 0; - let completion_tokens = response.completion_tokens || 0; - let total_tokens = response.total_tokens || 0; + let { usage } = response === null || response === void 0 ? void 0 : response.detail; + const { prompt_tokens = 0, completion_tokens = 0, total_tokens = 0 } = usage; let charge = deduct; if (isTokenBased === true) { charge = Math.ceil((deduct * total_tokens) / tokenFeeRatio);