Skip to content

Commit

Permalink
fix ai
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNotSus committed Feb 17, 2025
1 parent c3331e1 commit 9d6517c
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ llama-3.1-8b-instant
llama3-70b-8192
llama3-8b-8192
mixtral-8x7b-32768
llama-3.3-70b-versatile
llama-3.3-70b-specdec
llama-3.2-1b-preview
llama-3.2-3b-preview
deepseek-r1-distill-llama-70b
deepseek-r1-distill-qwen-32b
qwen-2.5-32b
qwen-2.5-coder-32b
`
.trim()
.split("\n")
Expand Down Expand Up @@ -58,8 +63,6 @@ app.use((req, res, next) => {
}
next();
});
const apiKeys = [process.env.API_KEY, process.env.API_KEY1];
randomAPIKey = apiKeys[Math.floor(Math.random() * apiKeys.length)];

app.post("/api/chat", async (req, res) => {
const { message, userId } = req.body;
Expand All @@ -82,10 +85,10 @@ app.post("/api/chat", async (req, res) => {
},
{
headers: {
Authorization: `Bearer ${randomAPIKey}`,
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
},
}
);
if (response.status === 429) {
switchModel();
Expand All @@ -102,7 +105,7 @@ app.post("/api/chat", async (req, res) => {
Authorization: `Bearer ${randomAPIKey}`,
"Content-Type": "application/json",
},
},
}
);
const aiResponse = response.data.choices[0].message.content;
conversation.push({ role: "assistant", content: aiResponse });
Expand Down Expand Up @@ -143,6 +146,7 @@ app.post("/api/chat", async (req, res) => {
res
.status(500)
.json({ error: "An error occurred while processing your request." });
console.log(error);
}
}
});
Expand Down Expand Up @@ -174,7 +178,7 @@ app.post("/api/signUp", async (req, res) => {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
},
}
);

if (!captchaVerifyResponse.data.success) {
Expand All @@ -194,14 +198,15 @@ app.post("/api/signUp", async (req, res) => {
Authorization: process.env.workerAUTH,
"Content-Type": "application/json",
},
},
}
);

res.status(200).json(response.data);
} catch (error) {
res
.status(500)
.json({ error: "An error occurred while processing your request." });
console.log(error);
}
});
app.post("/api/login", async (req, res) => {
Expand All @@ -223,7 +228,7 @@ app.post("/api/login", async (req, res) => {
Authorization: process.env.workerAUTH,
"Content-Type": "application/json",
},
},
}
);

res.status(200).json(response.data);
Expand All @@ -249,7 +254,7 @@ app.post("/api/checkPremium", async (req, res) => {
Authorization: process.env.workerAUTH,
"Content-Type": "application/json",
},
},
}
);

res.status(200).json(response.data);
Expand Down Expand Up @@ -277,7 +282,7 @@ app.post("/api/uploadSave", async (req, res) => {
Authorization: process.env.workerAUTH,
"Content-Type": "application/json",
},
},
}
);

res.status(200).json(response.data);
Expand All @@ -303,7 +308,7 @@ app.post("/api/readSave", async (req, res) => {
Authorization: process.env.workerAUTH,
"Content-Type": "application/json",
},
},
}
);

res.status(200).json(response.data);
Expand All @@ -312,10 +317,10 @@ app.post("/api/readSave", async (req, res) => {
}
});

// app.use((req, res, next) => {
// res.setHeader("X-Frame-Options", "SAMEORIGIN");
// next();
// });
app.use((req, res, next) => {
res.setHeader("X-Frame-Options", "SAMEORIGIN");
next();
});
app.use(express.static(path.join(__dirname, "static")));
app.use((req, res, next) => {
if (req.method === "GET" && !path.extname(req.url)) {
Expand Down

0 comments on commit 9d6517c

Please sign in to comment.