diff --git a/assets/emptyMessages.js b/assets/emptyMessages.js new file mode 100644 index 0000000..c712f18 --- /dev/null +++ b/assets/emptyMessages.js @@ -0,0 +1,32 @@ +const emptyResponses = [ + "Oh boy, this is a tough one! Unfortunately, I don't have much insight to share on this topic.", + "Hmm, I'm scratching my head on this one. Sorry to say that I don't have much to offer.", + "Wish I had a witty remark, but alas, I don't have much to contribute to this discussion.", + "Gosh, I'm usually quite chatty, but on this matter, I'm afraid I don't have much to say.", + "Hate to be the bearer of bad news, but I don't have much information to share on this subject.", + "Oh no, I think I'm drawing a blank here. Sorry to disappoint, but I don't have much to add.", + "I'm afraid I'm not much of an expert in this area, so I don't have much expertise to share.", + "I'm stumped on this one, sorry. I don't have much to offer on this front.", + "Bummer! I wish I had some profound wisdom to share, but I don't have much to say on this topic.", + "I'm sorry, but my brain is feeling a bit foggy today, and I don't have much knowledge on this subject.", + "Honestly, I feel like a fish out of water here. I don't have much to contribute to this debate.", + "I'm usually full of opinions, but on this matter, I'm afraid I don't have much to say.", + "I'm afraid I don't have much experience in this area, so I can't be of much help.", + "Sorry to say, but I don't have much to offer in that regard. Next topic, please?", + "Oh dear, I don't want to disappoint, but I don't have much to say on this issue.", + "I'm not the brightest bulb in the box when it comes to this topic, so I don't have much expertise to share.", + "I'm sorry, but I don't have much to contribute to this discussion at the moment.", + "I'm not feeling too confident about my knowledge in this area, so I don't have much insight to share.", + "I'm afraid I don't have much to say about that particular subject. Let's talk about something else?", + "Sorry, but I don't have much information on that area. Maybe try asking someone else?", + "I'm not the sharpest tool in the shed on this one, so I don't have much to offer on this topic.", + "My mind is drawing a blank here, sorry to say. I don't have much to add to this conversation.", + "I'm afraid I'm not much of an authority on this matter, so I don't have much expertise to share.", + "I'm usually full of banter, but on this subject, I'm afraid I don't have much to say.", + "I'm sorry, but my brain is feeling a bit scattered today, and I don't have much knowledge on this topic.", + "Honestly, I'm a bit lost on this one, so I don't have much to contribute to this debate.", + "I'm afraid I don't have much experience with this, so I can't be of much help.", + "I wish I had some grand insight to share, but alas, I don't have much to offer in that regard." + ]; + + module.exports = emptyResponses; diff --git a/assets/errorMessages.js b/assets/errorMessages.js new file mode 100644 index 0000000..e6e7055 --- /dev/null +++ b/assets/errorMessages.js @@ -0,0 +1,32 @@ +const errorMessages = [ + "Uh oh, looks like something went awry! Try !reset to start fresh.", + "Oops, we hit a bump in the road! Give !reset a try to start anew.", + "We've encountered an error, but !reset can help us out! Give it a go.", + "Looks like something went wrong, but don't worry! !reset will give us a clean slate.", + "Oh no, we've hit a snag! Try !reset to see if that solves the issue.", + "Don't panic, but something went wrong. !reset can help us get back on track.", + "Sorry about that! Give !reset a try and we'll start over.", + "An error occurred, but we can fix it! Try !reset to start a fresh session.", + "Whoops! Something went wrong, but !reset can help us get back on track.", + "Looks like we hit a bump in the road. Give !reset a try to get us back on track.", + "We've encountered an issue, but don't worry! Try !reset to start anew.", + "Oh dear, something's not quite right. Give !reset a go to start over.", + "Oops, something went wrong. But don't worry, !reset will get us back on track!", + "Looks like we've encountered an error. Give !reset a try to start a new session.", + "Sorry about that! Give !reset a go and we'll start over.", + "An error occurred, but we can fix it! Try !reset to start over.", + "Uh oh, something went wrong. But don't worry, !reset can help us out.", + "Looks like we hit a roadblock, but !reset can get us back on track!", + "We've encountered a problem, but don't fret! Give !reset a try to start anew.", + "Oopsie daisy! Give !reset a try and we'll start over." + ]; + + module.exports = errorMessages; + + + + + + + + \ No newline at end of file diff --git a/assets/resetMessages.js b/assets/resetMessages.js new file mode 100644 index 0000000..98e71cf --- /dev/null +++ b/assets/resetMessages.js @@ -0,0 +1,24 @@ +const resetResponses = [ + "Whoops, let's start fresh! What can I assist you with now?", + "Looks like we need a fresh start! What do you need help with?", + "To avoid any gremlins in the system, let's reset! How can I assist you now?", + "I'm hitting the reset button, so let's get back to business! What can I help you with today?", + "Let's wipe the slate clean and try again! What can I help you with now?", + "Alright, let's start over and get back on track! What do you need help with?", + "I'm giving our conversation a fresh start to avoid any bugs. How can I assist you now?", + "We're starting from square one to make sure everything's running smoothly. What can I help you with?", + "Time for a do-over! What do you need help with?", + "A reset should do the trick! What can I help you with now?", + "Let's hit the reset button and get back to solving problems. What do you need help with?", + "I'm wiping the slate clean so we can get back on track. What do you need assistance with now?", + "Let's start again to avoid any technical hiccups. What can I help you with now?", + "A fresh start is just what we need! How can I assist you now?", + "I'm resetting our conversation to avoid any more glitches. What can I help you with today?", + "I'm rebooting our chat to make sure everything runs smoothly. What can I assist you with now?", + "Sometimes a fresh start is the best approach! What do you need help with?", + "I'm starting us anew to avoid any pesky bugs. What can I help you with today?", + "To keep things running smoothly, I'm resetting our conversation. What can I help you with?", + "Let's hit the restart button to make sure we're on the right track. What can I help you with now?" + ]; + + module.exports = resetResponses; diff --git a/llamabot.js b/llamabot.js index dda9cfb..bf3c582 100644 --- a/llamabot.js +++ b/llamabot.js @@ -1,5 +1,9 @@ const Discord = require('discord.js'); const fetch = require('node-fetch'); +const emptyResponses = require('./assets/emptyMessages.js'); +const resetResponses = require('./assets/resetMessages.js'); +const errorMessages = require('./assets/errorMessages.js'); + require('dotenv').config() // hi const { Client, GatewayIntentBits, ActivityType, Partials } = require('discord.js'); @@ -33,7 +37,7 @@ client.on('messageCreate', async (message) => { if (message.channel.id !== channelID && message.channel.id !== channelID2) { return; } - if (message.author.bot) return; // Ignore messages from bots + if (message.author.bot) return; // Ignore messages from bots if (conversations.get(message.author.id)?.busy) { message.delete() @@ -52,8 +56,8 @@ client.on('messageCreate', async (message) => { conversation.messages.push({ role: 'user', content: message.cleanContent }); } else { - // Append user message to conversation history - conversation.messages.push({ role: 'user', content: message.cleanContent }); + // Append user message to conversation history + conversation.messages.push({ role: 'user', content: message.cleanContent }); } if (message.content === '!reset' || message.content === '!r') { conversations.delete(userID); // Delete user's conversation map if they request reset @@ -75,18 +79,22 @@ client.on('messageCreate', async (message) => { if (response && response.trim()) { // Send response to user if it's not empty await message.channel.send(response); + conversation.busy = false; } else { // Handle empty response here - await message.channel.send("Sorry, I don't have much to say about that."); - // Auto delete the map if the user creates an empty respose from the AI + const randomResponse = emptyResponses[Math.floor(Math.random() * emptyResponses.length)]; + // We had an empty response, create a new memory map for sanity. + await message.channel.send(randomResponse); // give the user a human like reponse about the error conversations.delete(userID); // Delete user's conversation map if they request reset - await message.channel.send('To avoid bugs, I reset our conversation, what can I help you with?'); + const resetMessage = resetResponses[Math.floor(Math.random() * resetResponses.length)]; + await message.channel.send(resetMessage); // give a notification of reset using a human like response. + conversation.busy = false; } conversations.set(userID, conversation); // Update user's conversation map in memory } catch (err) { console.error(err); - await message.channel.send('Oops, something went wrong!\nYou can try !reset which will start a new session.'); - } finally { + const errorMessage = errorMessages[Math.floor(Math.random() * errorMessages.length)]; + await message.channel.send(errorMessage); // give a notification of reset using a human like response. } finally { conversation.busy = false; } }); @@ -104,7 +112,7 @@ async function generateResponse(conversation) { 'accept': 'application/json', 'Content-Type': 'application/json' }, - body: JSON.stringify({ messages: conversation.messages}), + body: JSON.stringify({ messages: conversation.messages }), signal: controller.signal });