This commit is contained in:
sky
2025-10-13 16:09:27 -04:00
parent 1bb39463e4
commit ba9b82cf21
6 changed files with 485 additions and 36 deletions

View File

@ -14,7 +14,7 @@ import { search, download } from "./accounts/music.js";
import { banUser, removeAccount, verifyCookie, getUserFromCookie, createAccount, resetPassword, loginAccount, addBadge } from "./accounts/manage.js";
import { } from "./accounts/misc.js";
import { getRawData, generateAccountPage, editProfile, saveData, getUsers, isAdmin, retrieveData } from "./accounts/profile.js";
// import { infiniteCraft, chatBot } from "./ai.js";
import { callAI } from "./ai.js";
import os from "node:os";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@ -48,7 +48,7 @@ wss.on("connection", function connection(ws, req, res) {
ws.send(`online=${wss.clients.size}`);
setInterval(() => {
ws.send(`online=${wss.clients.size}`);
}, 5000);
}, 10000);
ws.on("error", console.error);
@ -137,20 +137,12 @@ app.post("/api/account/upload", async (req, res, next) => {
}
});
// ai endpoints
app.post("/api/ai/createChat", async (req, res) => {
// create chat in database and store some metadata about it
// ie: last model, time created, etc etc
})
app.post("/api/ai/sendMessage", async (req, res) => {
// take in chat id and message
// stream back reply
})
app.get("/api/ai/messages", async (req, res) => {
// take in chat id
// use unique uuid to store every chat
// return messages
})
// friends endpoints
app.get("/api/friends/list", async (req, res) => {
// use auth token to get user
@ -226,7 +218,6 @@ app.use("/api/stats", async (req, res, next) => {
// "cpu": os.cpus(),
"ram": `${(os.totalmem()-os.freemem())/1000000000}GB / ${os.totalmem()/1000000000}GB`,
"cpuUsage": os.loadavg(),
"openWebSockets": openSockets,
"uptime": `${os.uptime()}s`
});
} else {