Compare commits

..

No commits in common. "6ab972368acbe45476f647a8e9ffa3d599184c9e" and "1abaa24a2b97ead2d32a626794178a31de00ed07" have entirely different histories.

1 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
//IRC bot that responds to !chat, queries the chatgpt api, and prints the response line by line //IRC bot that responds to !chat, queries the chatgpt api, and prints the response line by line
const fs = require('fs');
const irc = require('irc'); const irc = require('irc');
const axios = require('axios'); const axios = require('axios');
const config = require('./config.json'); const config = require('./config.json');
@ -52,9 +51,9 @@ class Context {
} }
} }
let context = null; let context = new Context(savedMessages);
if (fs.existsSync('./messages.json')) { if (fs.existsSync('./messages.json')) {
const savedMessages = require('./messages.json'); savedMessages = require('./messages.json');
context = new Context(savedMessages); context = new Context(savedMessages);
} else { } else {
context = new Context(seed_messages); context = new Context(seed_messages);
@ -77,7 +76,7 @@ client.addListener('message', async (from, to, message) => {
if(is_chat_cmd && !config.alwaysRemember) { if(is_chat_cmd && !config.alwaysRemember) {
context.clear(); context.clear();
} }
context.add_user_prompt(message); context.add_user_prompt(query);
const query = message.slice(6); const query = message.slice(6);
try { try {
await chatgpt(query, context.messages, handleChatGPTResponseLine); await chatgpt(query, context.messages, handleChatGPTResponseLine);