diff --git a/README.md b/README.md index 82097ef..9306e8a 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,6 @@ To connect to an altready made topic (room) pass the hash on start up: /login [API KEY] - Login to the API -<<<<<<< HEAD -\> command here - Send a command to your container - -\> cd /to/path - change working directory -======= \>command here - Send a command to your container \> cd /to/path - Change your working directory. @@ -70,6 +65,7 @@ To connect to an altready made topic (room) pass the hash on start up: /stats - Get the containers stats +! [prompt] - Send a prompt to GPT3 ## Screenshots: diff --git a/sshChat.mjs b/sshChat.mjs index 6e25312..6e5fd8b 100644 --- a/sshChat.mjs +++ b/sshChat.mjs @@ -87,6 +87,14 @@ async function getStats(key) { return getStats.body } +async function AIRequest(prompt) { + let AIRequest = await unirest + .post('https://codex-ai-v9q6.onrender.com/') + .headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' }) + .send({ "prompt": prompt }) + return AIRequest.body.bot +} + swarm.on('connection', conn => { const name = b4a.toString(conn.remotePublicKey, 'hex') console.log(`* got a connection from ${name} (${USERNAME}) *`) @@ -150,6 +158,19 @@ rl.on('line', input => { }) } + const AI = input.startsWith("!") + if (AI) { + let inputdata = input.split(2) + const prompt = inputdata.join(" ").replace("> ", "").replace(">", "") + AIRequest(prompt).then((data) => { + console.log(data) + for (const conn of conns) { + conn.write(`${USERNAME} ran ${cmdToRun}: \n` + data) + } + }) + } + + const start = input.startsWith("/start") if (start) { startContainer(DAPI_KEY.key).then((data) => { @@ -172,7 +193,7 @@ rl.on('line', input => { const restart = input.startsWith("/restart") if (restart) { - startContainer(DAPI_KEY.key).then((data) => { + restartContainer(DAPI_KEY.key).then((data) => { console.log(data) for (const conn of conns) { conn.write(`${USERNAME} ran restart.`) @@ -191,7 +212,9 @@ rl.on('line', input => { } else { // if (!LOGGEDIN) return console.log("Please login using /login [API KEY]") - if (input.startsWith("/")) return + if (input.startsWith("/") || input.startsWith("!")) return + + if (input = "") return for (const conn of conns) { conn.write(`${USERNAME}: ${input}`)