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 {
|
||||
|
||||
|
||||
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) {
|
||||
const response = await fetch(`http://${server}:7860/run/textgen`, {
|
||||
|
|
@ -18,20 +47,57 @@ class Fourchat {
|
|||
--- 865467536
|
||||
${input_text}
|
||||
--- 865467537
|
||||
>>865467536
|
||||
`,
|
||||
200,
|
||||
true,
|
||||
1.99,
|
||||
0.18,
|
||||
1,
|
||||
1.15,
|
||||
30,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
false,
|
||||
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_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() {
|
||||
this.matches = [ "4chat", "botmention" ];
|
||||
this.matches = [ "4chat", "botmention", "botrandom" ];
|
||||
}
|
||||
|
||||
async action(msg) {
|
||||
async action(msg, botrandom) {
|
||||
let chan = msg.channel;
|
||||
try {
|
||||
const input_text = msg.content.replace("!4chat","").replace(/<@.+?>/,"anon").trim();
|
||||
console.log(`Input Text: ${input_text}`);
|
||||
const output_json = await this.prompt(input_text);
|
||||
const output_text = (output_json.data[0]);
|
||||
const trimmed_text = this.find_response(output_text);
|
||||
chan.send(trimmed_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_text = (output_json.data[0]);
|
||||
const trimmed_text = this.find_response(output_text);
|
||||
console.log(`Generated Message: ${trimmed_text}`);
|
||||
chan.send(trimmed_text);
|
||||
}
|
||||
} catch (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.on('ready', () => {
|
||||
console.log(`Logged into Discord as ${client.user.tag}`);
|
||||
client.user.setActivity('with the bots', { type: Discord.ActivityType.Playing });
|
||||
});
|
||||
client.on('messageCreate', async (msg) => {
|
||||
for(const t in triggers) {
|
||||
|
|
@ -57,6 +58,10 @@ async function main() {
|
|||
console.log(`Bot mentioned.`);
|
||||
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) => {
|
||||
if (reaction.partial) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue