Updated 4chan bot params
This commit is contained in:
parent
6f0040e9a5
commit
7d735f5785
|
|
@ -7,6 +7,35 @@ const server = "192.168.1.70";
|
||||||
class Fourchat {
|
class Fourchat {
|
||||||
|
|
||||||
|
|
||||||
|
async random_prompt() {
|
||||||
|
const response = await fetch(`http://${server}:7860/run/textgen`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
data: [
|
||||||
|
`-----
|
||||||
|
--- 865467536
|
||||||
|
`,
|
||||||
|
250, //max tokens
|
||||||
|
true, //do_sample
|
||||||
|
0.63, //temperature
|
||||||
|
0.98, //top_p
|
||||||
|
1, //typical_p
|
||||||
|
1.05, //rep penalty
|
||||||
|
0, //top_k
|
||||||
|
0, //min_length
|
||||||
|
0, //no_repeat_ngram_size
|
||||||
|
1, //num_beams
|
||||||
|
0, //penalty_alpha
|
||||||
|
1, //length_penalty
|
||||||
|
false, //early_stopping
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const response_json = await response.json();
|
||||||
|
return response_json;
|
||||||
|
}
|
||||||
|
|
||||||
async prompt(input_text) {
|
async prompt(input_text) {
|
||||||
const response = await fetch(`http://${server}:7860/run/textgen`, {
|
const response = await fetch(`http://${server}:7860/run/textgen`, {
|
||||||
|
|
@ -18,20 +47,57 @@ class Fourchat {
|
||||||
--- 865467536
|
--- 865467536
|
||||||
${input_text}
|
${input_text}
|
||||||
--- 865467537
|
--- 865467537
|
||||||
|
>>865467536
|
||||||
`,
|
`,
|
||||||
200,
|
250, //max tokens
|
||||||
true,
|
true, //do_sample
|
||||||
1.99,
|
0.63, //temperature
|
||||||
0.18,
|
0.98, //top_p
|
||||||
1,
|
1, //typical_p
|
||||||
1.15,
|
1.05, //rep penalty
|
||||||
30,
|
0, //top_k
|
||||||
0,
|
0, //min_length
|
||||||
0,
|
0, //no_repeat_ngram_size
|
||||||
1,
|
1, //num_beams
|
||||||
0,
|
0, //penalty_alpha
|
||||||
1,
|
1, //length_penalty
|
||||||
false,
|
false, //early_stopping
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const response_json = await response.json();
|
||||||
|
return response_json;
|
||||||
|
}
|
||||||
|
|
||||||
|
async prompt_reply(input_text1,input_text2) {
|
||||||
|
const response = await fetch(`http://${server}:7860/run/textgen`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
data: [
|
||||||
|
`-----
|
||||||
|
--- 865467535
|
||||||
|
${input_text1}
|
||||||
|
--- 865467536
|
||||||
|
>>865467535
|
||||||
|
${input_text2}
|
||||||
|
--- 865467537
|
||||||
|
>>865467536
|
||||||
|
`,
|
||||||
|
250, //max tokens
|
||||||
|
true, //do_sample
|
||||||
|
0.63, //temperature
|
||||||
|
0.98, //top_p
|
||||||
|
1, //typical_p
|
||||||
|
1.05, //rep penalty
|
||||||
|
0, //top_k
|
||||||
|
0, //min_length
|
||||||
|
0, //no_repeat_ngram_size
|
||||||
|
1, //num_beams
|
||||||
|
0, //penalty_alpha
|
||||||
|
1, //length_penalty
|
||||||
|
false, //early_stopping
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
@ -49,18 +115,37 @@ ${input_text}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.matches = [ "4chat", "botmention" ];
|
this.matches = [ "4chat", "botmention", "botrandom" ];
|
||||||
}
|
}
|
||||||
|
|
||||||
async action(msg) {
|
async action(msg, botrandom) {
|
||||||
let chan = msg.channel;
|
let chan = msg.channel;
|
||||||
try {
|
try {
|
||||||
const input_text = msg.content.replace("!4chat","").replace(/<@.+?>/,"anon").trim();
|
const input_text = msg.content.replace("!4chat","").replace(/<@.+?>/,"anon").trim();
|
||||||
console.log(`Input Text: ${input_text}`);
|
console.log(`Input Text: ${input_text}`);
|
||||||
|
await chan.sendTyping();
|
||||||
|
if (botrandom == "botrandom" || msg.content.startsWith('!botrandom')) {
|
||||||
|
const output_json = await this.random_prompt();
|
||||||
|
const output_text = (output_json.data[0]);
|
||||||
|
const startIndex = output_text.indexOf("865467536");
|
||||||
|
const output_only = output_text.slice(startIndex+9).split("---")[0].trim();
|
||||||
|
console.log(`Generating random nonsense: ${output_only}`);
|
||||||
|
chan.send(output_only);
|
||||||
|
} else if (msg.reference) {
|
||||||
|
const repliedTo = await msg.channel.messages.fetch(msg.reference.messageId);
|
||||||
|
const oldReply = repliedTo.content;
|
||||||
|
const output_json = await this.prompt_reply(oldReply,input_text);
|
||||||
|
const output_text = (output_json.data[0]);
|
||||||
|
const trimmed_text = this.find_response(output_text);
|
||||||
|
console.log(`Generated Reply: ${trimmed_text}`);
|
||||||
|
chan.send(trimmed_text);
|
||||||
|
} else {
|
||||||
const output_json = await this.prompt(input_text);
|
const output_json = await this.prompt(input_text);
|
||||||
const output_text = (output_json.data[0]);
|
const output_text = (output_json.data[0]);
|
||||||
const trimmed_text = this.find_response(output_text);
|
const trimmed_text = this.find_response(output_text);
|
||||||
|
console.log(`Generated Message: ${trimmed_text}`);
|
||||||
chan.send(trimmed_text);
|
chan.send(trimmed_text);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
chan.send(`Error: ${e}`);
|
chan.send(`Error: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
main.js
5
main.js
|
|
@ -44,6 +44,7 @@ async function main() {
|
||||||
client.login('MzYyNzU1MzE3MTczNTgzODcy.DK3R1A.8M22ZkNaaoHy-ifBQwVivSU7svY');
|
client.login('MzYyNzU1MzE3MTczNTgzODcy.DK3R1A.8M22ZkNaaoHy-ifBQwVivSU7svY');
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
console.log(`Logged into Discord as ${client.user.tag}`);
|
console.log(`Logged into Discord as ${client.user.tag}`);
|
||||||
|
client.user.setActivity('with the bots', { type: Discord.ActivityType.Playing });
|
||||||
});
|
});
|
||||||
client.on('messageCreate', async (msg) => {
|
client.on('messageCreate', async (msg) => {
|
||||||
for(const t in triggers) {
|
for(const t in triggers) {
|
||||||
|
|
@ -57,6 +58,10 @@ async function main() {
|
||||||
console.log(`Bot mentioned.`);
|
console.log(`Bot mentioned.`);
|
||||||
await bot_modules[triggers['botmention']].action(msg);
|
await bot_modules[triggers['botmention']].action(msg);
|
||||||
}
|
}
|
||||||
|
if (Math.random() < 0.02) {
|
||||||
|
console.log(`Bot random event triggered.`);
|
||||||
|
await bot_modules[triggers['botrandom']].action(msg, "botrandom");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
client.on('messageReactionAdd', async (reaction, user) => {
|
client.on('messageReactionAdd', async (reaction, user) => {
|
||||||
if (reaction.partial) {
|
if (reaction.partial) {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue