56678dc8 by Jonille Arreglo

31466_limited_usage_chatbot+

1 parent 2b954ae6
Showing 1 changed file with 6 additions and 6 deletions
...@@ -195,7 +195,7 @@ async function runGPTTurbo(req, res) { ...@@ -195,7 +195,7 @@ async function runGPTTurbo(req, res) {
195 const moderation = await axios.post("https://api.openai.com/v1/moderations", { 195 const moderation = await axios.post("https://api.openai.com/v1/moderations", {
196 input: query_prompt 196 input: query_prompt
197 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } }); 197 }, { headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` } });
198 198
199 const validate = await validation(aiwp_app_id, req, res); 199 const validate = await validation(aiwp_app_id, req, res);
200 if(!validate) return; 200 if(!validate) return;
201 const { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE} = validate; 201 const { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE} = validate;
...@@ -276,11 +276,11 @@ async function runOpensource(req, res) { ...@@ -276,11 +276,11 @@ async function runOpensource(req, res) {
276 var input = ''; 276 var input = '';
277 const message_history = JSON.parse(message); 277 const message_history = JSON.parse(message);
278 const query_prompt = message_history.length ? message_history[message_history.length - 1].content : ""; 278 const query_prompt = message_history.length ? message_history[message_history.length - 1].content : "";
279 279
280 const validate = await validation(aiwp_app_id, req, res); 280 const validate = await validation(aiwp_app_id, req, res);
281 if(!validate) return; 281 if(!validate) return;
282 const { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE} = validate; 282 const { IS_FREE_USER, aiwp_logged_in, TRIED_USAGE} = validate;
283 283
284 try { 284 try {
285 let error_msg = ""; 285 let error_msg = "";
286 const endpoint_api_url = get_endpoint_api_url(currentModel); 286 const endpoint_api_url = get_endpoint_api_url(currentModel);
...@@ -367,7 +367,7 @@ async function authenticate(params) { ...@@ -367,7 +367,7 @@ async function authenticate(params) {
367 body: JSON.stringify(params), 367 body: JSON.stringify(params),
368 referrer: "https://chatgpt.ai-pro.org" 368 referrer: "https://chatgpt.ai-pro.org"
369 }); 369 });
370 370
371 return await data.json(); 371 return await data.json();
372 } 372 }
373 373
...@@ -422,7 +422,7 @@ async function setChatUsage(params) { ...@@ -422,7 +422,7 @@ async function setChatUsage(params) {
422 422
423 async function validation (aiwp_app_id, req, res) { 423 async function validation (aiwp_app_id, req, res) {
424 const aiwp_logged_in = req.cookies[user_secret_id] ? decodeURIComponent(req.cookies[user_secret_id]) : ""; 424 const aiwp_logged_in = req.cookies[user_secret_id] ? decodeURIComponent(req.cookies[user_secret_id]) : "";
425 const limit = req.cookies["WcvYPABR"] ? parseInt(req.cookies["WcvYPABR"].replace(/\D/g, '')) : -1; 425 const limit = req.cookies["WcvYPABR"] ? parseInt(req.cookies["WcvYPABR"].replace(/\D/g, '')) : 3;
426 let IS_FREE_USER = false; 426 let IS_FREE_USER = false;
427 let TRIED_USAGE = 0; 427 let TRIED_USAGE = 0;
428 428
...@@ -459,7 +459,7 @@ async function validation (aiwp_app_id, req, res) { ...@@ -459,7 +459,7 @@ async function validation (aiwp_app_id, req, res) {
459 if (data.usage !== null) { 459 if (data.usage !== null) {
460 TRIED_USAGE = parseInt(data.usage); 460 TRIED_USAGE = parseInt(data.usage);
461 } 461 }
462 462
463 } 463 }
464 if (IS_FREE_USER && TRIED_USAGE >= limit) { 464 if (IS_FREE_USER && TRIED_USAGE >= limit) {
465 res.json({ status: "invalid", limited: true }); 465 res.json({ status: "invalid", limited: true });
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!