mirror of
https://github.com/System-End/slack-end.git
synced 2026-04-19 18:35:19 +00:00
feat: zeon ai
This commit is contained in:
parent
5bfb6b1eba
commit
5e5c8be465
4 changed files with 106 additions and 12 deletions
|
|
@ -18,11 +18,12 @@
|
|||
"simple-json-db": "^2.0.0",
|
||||
"smee-client": "^2.0.3",
|
||||
"stegcloak": "^1.1.1",
|
||||
"ws": "^8.18.0"
|
||||
"ws": "^8.18.0",
|
||||
"openai": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.7.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,17 +27,7 @@ const clean = async (text) => {
|
|||
// Send off the cleaned up result
|
||||
return text;
|
||||
};
|
||||
//eg: zeon can you set a timer for 10 minutes
|
||||
// plan: use ai to parse it for ME ONLY
|
||||
// everyone else act like a nice soul and use if statements
|
||||
/**
|
||||
* Only respond in JSON, no codeblock. Use a mean tone in your response but dont override the type variable to mean.in your json please give a property of type based on what the user is asking. All timestamps must be in unix. All durations must be in miliseconds.
|
||||
|
||||
The users'sprompt is: zeon can you tell me what 1+1 is <ac prompt>
|
||||
*/
|
||||
function zeonMessageCommands(d, r) {
|
||||
// TODO: im eepy buddy
|
||||
}
|
||||
export default class Message implements Command {
|
||||
name: string;
|
||||
description: string;
|
||||
|
|
|
|||
99
src/commands/zeon_message.ts
Normal file
99
src/commands/zeon_message.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
// @ts-nocheck
|
||||
import { App } from "@slack/bolt";
|
||||
import util from "util";
|
||||
import { Command, onlyForMe } from "../modules/BaseCommand";
|
||||
import OpenAI from 'openai';
|
||||
const ai = new OpenAI({
|
||||
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
|
||||
});
|
||||
//eg: zeon can you set a timer for 10 minutes
|
||||
// plan: use ai to parse it for ME ONLY
|
||||
// everyone else act like a nice soul and use if statements
|
||||
/**
|
||||
* Only respond in JSON, no codeblock. Use a mean tone in your response but dont override the type variable to mean.in your json please give a property of type based on what the user is asking. All timestamps must be in unix. All durations must be in miliseconds.
|
||||
|
||||
The users'sprompt is: zeon can you tell me what 1+1 is <ac prompt>
|
||||
*/
|
||||
function zeonMessageCommands(d, r) {
|
||||
// TODO: im eepy buddy
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default class Message implements Command {
|
||||
name: string;
|
||||
description: string;
|
||||
is_event?: boolean;
|
||||
constructor() {
|
||||
this.name = `message`;
|
||||
this.description = `Handles zeon.`;
|
||||
this.is_event = true;
|
||||
}
|
||||
run(app: App) {
|
||||
// app.command()
|
||||
app.event(this.name, async (par) => {
|
||||
// console.debug(par);
|
||||
// if (!par.ack) return;
|
||||
// console.debug(0);
|
||||
if (!par.say) return;
|
||||
// console.log(
|
||||
// `uh one of them are here`,
|
||||
// par.event.text,
|
||||
// par.event.channel_type,
|
||||
// );
|
||||
//@ts-ignore
|
||||
// await par.ack();
|
||||
if (!par.event.text.startsWith("zeon")) return;
|
||||
console.debug(`cmd`);
|
||||
const { event, say } = par;
|
||||
|
||||
const args = event.text.slice("zeon ".length).trim().split(/ +/);
|
||||
const cmd = args.shift().toLowerCase();
|
||||
if (onlyForMe(command.user_id)) {
|
||||
let prompt = `Only respond in JSON, no codeblock. Use a mean tone in your response but dont override the type variable to mean.in your json please give a property of type based on what the user is asking. All timestamps must be in unix. All durations must be in miliseconds. `
|
||||
const aiReq = await ai.chat.completions.create({
|
||||
messages: [{role: 'system', content: prompt },{ role: 'user', content: event.text }],
|
||||
model: 'gpt-3.5-turbo',
|
||||
});
|
||||
const m = await app.client.postMessage({
|
||||
channel: event.channel,
|
||||
text: aiReq.message || ":notcool: i didnt get a message im very scared... >> " + JSON.stringify(aiReq),
|
||||
})
|
||||
switch (aiReq.type) {
|
||||
case "reminder":
|
||||
case "timer":
|
||||
// uhhh todo??
|
||||
setTimeout(() => {
|
||||
app.client.chat.postMessage({
|
||||
channel: event.channel,
|
||||
text: "reminder time",
|
||||
thread_ts: m.ts
|
||||
})
|
||||
}, aiReq.duration)
|
||||
break;
|
||||
default:
|
||||
console.log(aiReq, `unk`)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
// console.log(cmd, args);
|
||||
const actionVerbs = ["can", "please", "plz"]
|
||||
const uneededVerbsInSomeCases = ["you", "a"]
|
||||
if (actionVerbs.includes(cmd)) {
|
||||
// try to understand
|
||||
if (uneededVerbsInSomeCases.includes(args[0].toLowerCase())) {
|
||||
args.shift() // get rid of it
|
||||
// timer func
|
||||
}
|
||||
}
|
||||
}
|
||||
console.debug(`#message3-`);
|
||||
|
||||
//@ts-ignore
|
||||
// await say(`Hi there! im a WIP rn but my site is:\n> http://zeon.rocks/`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
4
src/modules/watchMyLocation.ts
Normal file
4
src/modules/watchMyLocation.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export default function watchLocation() {
|
||||
const location = null;
|
||||
// todo
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue