439c4058 by Marwin Cañeta

#1: Token count does not update on User Dashboard and Master Dashboard

1 parent 25cf9790
Showing 1 changed file with 21 additions and 5 deletions
...@@ -235,10 +235,18 @@ async function runGPTTurbo(req, res) { ...@@ -235,10 +235,18 @@ async function runGPTTurbo(req, res) {
235 } catch (e) { 235 } catch (e) {
236 console.log('Error encoding prompt text', e); 236 console.log('Error encoding prompt text', e);
237 } 237 }
238
238 let usage_params = { 239 let usage_params = {
239 "aiwp_logged_in": aiwp_logged_in, "app": "chatbot+", "prompt_token": usage.prompt_tokens, "total_token": usage.total_tokens, "aiwp_app_id":aiwp_app_id , "usage_tries": TRIED_USAGE, ipdflu: getClientIP(req) 240 "aiwp_logged_in": aiwp_logged_in,
241 "app": "chatbot+",
242 "prompt_token": usage.prompt_tokens,
243 "total_token": usage.total_tokens,
244 "aiwp_app_id": aiwp_app_id,
245 "usage_tries": TRIED_USAGE,
246 ipdflu: getClientIP(req)
240 }; 247 };
241 if(IS_FREE_USER) { 248
249 if (IS_FREE_USER) {
242 await setUsage(usage_params); 250 await setUsage(usage_params);
243 } else { 251 } else {
244 await setChatUsage(usage_params); 252 await setChatUsage(usage_params);
...@@ -330,12 +338,20 @@ async function runOpensource(req, res) { ...@@ -330,12 +338,20 @@ async function runOpensource(req, res) {
330 } 338 }
331 } finally { 339 } finally {
332 let usage_params = { 340 let usage_params = {
333 "aiwp_logged_in": aiwp_logged_in, "app": "chatbot+", "prompt_token": usage.prompt_tokens, "total_token": usage.total_tokens, "aiwp_app_id":aiwp_app_id , "usage_tries": TRIED_USAGE, ipdflu: getClientIP(req) 341 "aiwp_logged_in": aiwp_logged_in,
342 "app": "chatbot+",
343 "prompt_token": usage.prompt_tokens,
344 "total_token": usage.total_tokens,
345 "aiwp_app_id": aiwp_app_id,
346 "usage_tries": TRIED_USAGE,
347 ipdflu: getClientIP(req)
334 }; 348 };
335 349
336 if(IS_FREE_USER) { 350 if (IS_FREE_USER) {
337 await setUsage(usage_params); 351 await setUsage(usage_params);
338 } 352 } else {
353 await setChatUsage(usage_params);
354 }
339 355
340 result_response = { 356 result_response = {
341 prompt: JSON.parse(message), 357 prompt: JSON.parse(message),
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!