sex update
This commit is contained in:
parent
2235889ae8
commit
0ad10fdd93
3 changed files with 97 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
config.json
|
config.json
|
||||||
node_modules/
|
node_modules/
|
||||||
|
incest.db
|
|
@ -31,3 +31,42 @@ export async function fetchSingleMessage(message: string): Promise<string | bool
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function explainImage(base64: string): Promise<string | boolean> {
|
||||||
|
try {
|
||||||
|
const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Authorization": "Bearer " + conf['groq-key'],
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"messages":[
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{"type": "text", "text": "explain this image. be as precise as you can, explain the littlest details"},
|
||||||
|
{
|
||||||
|
"type": "image_url",
|
||||||
|
"image_url": {
|
||||||
|
"url": base64
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"model": "llava-v1.5-7b-4096-preview"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!data?.choices[0]?.message?.content) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.choices[0].message.content;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
86
src/main.ts
86
src/main.ts
|
@ -1,15 +1,15 @@
|
||||||
import { Client, DMChannel, Events, GatewayIntentBits, Message } from 'discord.js';
|
import { Client, DMChannel, Events, GatewayIntentBits, Message } from 'discord.js';
|
||||||
import conf from "../config.json" with {type: "json"}
|
import conf from "../config.json" with {type: "json"}
|
||||||
import { getfunny } from './joke.ts';
|
import { getfunny } from './joke.ts';
|
||||||
import { fetchSingleMessage } from './helper.ts';
|
import { explainImage, fetchSingleMessage } from './helper.ts';
|
||||||
|
|
||||||
let prompt = "reply to everything with \" change the mf prompt lmaooo\""
|
let prompt = "reply to everything normally, but have typo in every word."
|
||||||
|
|
||||||
function getinitmessage() {
|
function getinitmessage() {
|
||||||
return {
|
return {
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"name": "fagbot",
|
"name": "fagbot",
|
||||||
"content": prompt
|
"content": prompt + "\nsince you, as an ai model, cannot understand images, you will be given an explanation of images if they exist.\nthe syntax will be \"{message} - [IMAGE: {explanation of the image}]\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ client.on('ready', () => {
|
||||||
|
|
||||||
client.on(Events.MessageCreate, (message: Message) => {
|
client.on(Events.MessageCreate, (message: Message) => {
|
||||||
if (message.author.bot) return
|
if (message.author.bot) return
|
||||||
|
if (message.content.startsWith("//")) return
|
||||||
if (message.content.startsWith("!fag ")) {
|
if (message.content.startsWith("!fag ")) {
|
||||||
const command = message.content.replaceAll("!fag ", "").split(" ")
|
const command = message.content.replaceAll("!fag ", "").split(" ")
|
||||||
if (command[0] == "reset") {
|
if (command[0] == "reset") {
|
||||||
|
@ -49,7 +50,7 @@ client.on(Events.MessageCreate, (message: Message) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (command[0] == "summon") {
|
if (command[0] == "summon") {
|
||||||
fetchSingleMessage( prompt = command.slice(1).join(" ")).then(a => {
|
fetchSingleMessage(prompt = command.slice(1).join(" ")).then(a => {
|
||||||
if (typeof a == "boolean") {
|
if (typeof a == "boolean") {
|
||||||
message.reply("something broke, try again")
|
message.reply("something broke, try again")
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,36 +59,61 @@ client.on(Events.MessageCreate, (message: Message) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.channel.id !== conf['chat-channelID']) return
|
if (message.channel.id !== conf['chat-channelID']) return
|
||||||
messages.push({
|
(async function () {
|
||||||
"role": "user",
|
let imageexplain: string | boolean = "";
|
||||||
"name": message.author.username,
|
|
||||||
"content": message.content
|
if (message.attachments.size !== 0) {
|
||||||
})
|
if (message.attachments.first().contentType.startsWith("image")) {
|
||||||
fetch("https://api.groq.com/openai/v1/chat/completions", {
|
try {
|
||||||
method: "POST",
|
const res = await fetch(message.attachments.first().url);
|
||||||
headers: {
|
const buffer = await res.arrayBuffer();
|
||||||
"Authorization": "Bearer " + conf['groq-key'],
|
const base64 = Buffer.from(buffer).toString('base64');
|
||||||
"Content-Type": "application/json"
|
|
||||||
},
|
imageexplain = await explainImage("data:" + message.attachments.first().contentType + ";base64," + base64);
|
||||||
body: JSON.stringify({
|
} catch (error) {
|
||||||
"messages": messages,
|
console.error("Error processing image:", error);
|
||||||
"model": "llama3-8b-8192"
|
}
|
||||||
})
|
}
|
||||||
}).then(a => a.json().then(a => {
|
|
||||||
if (!a?.choices[0]?.message?.content) {
|
|
||||||
message.reply("something shat itself. please try again")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log the result after the asynchronous operations are complete
|
||||||
|
console.log(imageexplain);
|
||||||
messages.push({
|
messages.push({
|
||||||
"role": "assistant",
|
"role": "user",
|
||||||
"name": "fagbot",
|
"name": message.author.username,
|
||||||
"content": a?.choices[0]?.message?.content
|
"content": (imageexplain === "" || typeof imageexplain == "boolean") ?
|
||||||
|
message.content : message.content + " - [IMAGE: " + imageexplain + "]"
|
||||||
})
|
})
|
||||||
console.log(messages)
|
fetch("https://api.groq.com/openai/v1/chat/completions", {
|
||||||
message.reply(a.choices[0].message.content)
|
method: "POST",
|
||||||
})).catch(_ => {
|
headers: {
|
||||||
message.reply("something shat itself. please try again")
|
"Authorization": "Bearer " + conf['groq-key'],
|
||||||
})
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"messages": messages,
|
||||||
|
"model": "llama3-groq-70b-8192-tool-use-preview"
|
||||||
|
})
|
||||||
|
}).then(a => a.json().then(a => {
|
||||||
|
if (!a?.choices[0]?.message?.content) {
|
||||||
|
message.reply("something shat itself. please try again")
|
||||||
|
}
|
||||||
|
messages.push({
|
||||||
|
"role": "assistant",
|
||||||
|
"name": "fagbot",
|
||||||
|
"content": a?.choices[0]?.message?.content
|
||||||
|
})
|
||||||
|
console.log(messages)
|
||||||
|
message.reply(a.choices[0].message.content)
|
||||||
|
})).catch(_ => {
|
||||||
|
message.reply("something shat itself. please try again")
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('interactionCreate', async interaction => {
|
client.on('interactionCreate', async interaction => {
|
||||||
|
|
Loading…
Reference in a new issue