Update
Showing
1 changed file
with
9 additions
and
10 deletions
| ... | @@ -79,11 +79,11 @@ const user_secret_id = process.env.USER_SECRET_ID || "aiwp_logged_in"; | ... | @@ -79,11 +79,11 @@ const user_secret_id = process.env.USER_SECRET_ID || "aiwp_logged_in"; |
| 79 | const aiwp_app_id = "chatbot+"; | 79 | const aiwp_app_id = "chatbot+"; |
| 80 | // Primary Open AI Route | 80 | // Primary Open AI Route |
| 81 | app.post('/api', async (req, res) => { | 81 | app.post('/api', async (req, res) => { |
| 82 | // if(!req.get('origin') || (!req.get('origin').includes(req.get('host')))) { | 82 | if(!req.get('origin') || (!req.get('origin').includes(req.get('host')))) { |
| 83 | // res.status(401); | 83 | res.status(401); |
| 84 | // res.send('Method Not Allowed'); | 84 | res.send('Method Not Allowed'); |
| 85 | // return; | 85 | return; |
| 86 | // } | 86 | } |
| 87 | const { message, currentModel, temperature } = req.body; | 87 | const { message, currentModel, temperature } = req.body; |
| 88 | 88 | ||
| 89 | if (currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") { | 89 | if (currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") { |
| ... | @@ -152,7 +152,7 @@ app.post('/api', async (req, res) => { | ... | @@ -152,7 +152,7 @@ app.post('/api', async (req, res) => { |
| 152 | console.log('Error encoding prompt text', e); | 152 | console.log('Error encoding prompt text', e); |
| 153 | } | 153 | } |
| 154 | let usage_params = { | 154 | let usage_params = { |
| 155 | aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE | 155 | "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 |
| 156 | }; | 156 | }; |
| 157 | if(IS_FREE_USER) { | 157 | if(IS_FREE_USER) { |
| 158 | await setUsage(usage_params); | 158 | await setUsage(usage_params); |
| ... | @@ -234,7 +234,7 @@ async function runGPTTurbo(req, res) { | ... | @@ -234,7 +234,7 @@ async function runGPTTurbo(req, res) { |
| 234 | console.log('Error encoding prompt text', e); | 234 | console.log('Error encoding prompt text', e); |
| 235 | } | 235 | } |
| 236 | let usage_params = { | 236 | let usage_params = { |
| 237 | aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE | 237 | "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 |
| 238 | }; | 238 | }; |
| 239 | if(IS_FREE_USER) { | 239 | if(IS_FREE_USER) { |
| 240 | await setUsage(usage_params); | 240 | await setUsage(usage_params); |
| ... | @@ -321,7 +321,7 @@ async function runOpensource(req, res) { | ... | @@ -321,7 +321,7 @@ async function runOpensource(req, res) { |
| 321 | console.log('Error encoding prompt text', e); | 321 | console.log('Error encoding prompt text', e); |
| 322 | } | 322 | } |
| 323 | let usage_params = { | 323 | let usage_params = { |
| 324 | aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE | 324 | "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 |
| 325 | }; | 325 | }; |
| 326 | if(IS_FREE_USER) { | 326 | if(IS_FREE_USER) { |
| 327 | await setUsage(usage_params); | 327 | await setUsage(usage_params); |
| ... | @@ -346,7 +346,6 @@ async function runOpensource(req, res) { | ... | @@ -346,7 +346,6 @@ async function runOpensource(req, res) { |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | async function authenticate(params) { | 348 | async function authenticate(params) { |
| 349 | console.log("params", params); | ||
| 350 | let data = await fetch(`${hostapi}/e/authenticate/v2`, { | 349 | let data = await fetch(`${hostapi}/e/authenticate/v2`, { |
| 351 | method: "POST", | 350 | method: "POST", |
| 352 | headers: { | 351 | headers: { |
| ... | @@ -438,7 +437,7 @@ async function validation (aiwp_app_id, req, res) { | ... | @@ -438,7 +437,7 @@ async function validation (aiwp_app_id, req, res) { |
| 438 | } else { | 437 | } else { |
| 439 | IS_FREE_USER = true; | 438 | IS_FREE_USER = true; |
| 440 | let data = await getLimitedUsage({ | 439 | let data = await getLimitedUsage({ |
| 441 | aiwp_app_id | 440 | "aiwp_app_id": aiwp_app_id |
| 442 | }); | 441 | }); |
| 443 | 442 | ||
| 444 | if (data.usage !== null) { | 443 | if (data.usage !== null) { | ... | ... |
-
Please register or sign in to post a comment