7c2be8ae by Leff Tubat

Update

1 parent 43b5f469
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";
const aiwp_app_id = "chatbot+";
// Primary Open AI Route
app.post('/api', async (req, res) => {
// if(!req.get('origin') || (!req.get('origin').includes(req.get('host')))) {
// res.status(401);
// res.send('Method Not Allowed');
// return;
// }
if(!req.get('origin') || (!req.get('origin').includes(req.get('host')))) {
res.status(401);
res.send('Method Not Allowed');
return;
}
const { message, currentModel, temperature } = req.body;
if (currentModel == "gpt-3.5-turbo" || currentModel == "gpt-3.5-turbo-0301") {
......@@ -152,7 +152,7 @@ app.post('/api', async (req, res) => {
console.log('Error encoding prompt text', e);
}
let usage_params = {
aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE
"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
};
if(IS_FREE_USER) {
await setUsage(usage_params);
......@@ -234,7 +234,7 @@ async function runGPTTurbo(req, res) {
console.log('Error encoding prompt text', e);
}
let usage_params = {
aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE
"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
};
if(IS_FREE_USER) {
await setUsage(usage_params);
......@@ -321,7 +321,7 @@ async function runOpensource(req, res) {
console.log('Error encoding prompt text', e);
}
let usage_params = {
aiwp_logged_in, app: 'chatbot+', prompt_token: usage.prompt_tokens, total_token: usage.total_tokens, aiwp_app_id, usage_tries: TRIED_USAGE
"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
};
if(IS_FREE_USER) {
await setUsage(usage_params);
......@@ -346,7 +346,6 @@ async function runOpensource(req, res) {
}
async function authenticate(params) {
console.log("params", params);
let data = await fetch(`${hostapi}/e/authenticate/v2`, {
method: "POST",
headers: {
......@@ -438,7 +437,7 @@ async function validation (aiwp_app_id, req, res) {
} else {
IS_FREE_USER = true;
let data = await getLimitedUsage({
aiwp_app_id
"aiwp_app_id": aiwp_app_id
});
if (data.usage !== null) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!