some random stuff and prompt changes

This commit is contained in:
Raven Scott 2023-04-10 01:10:48 +02:00
parent 5ac35ca6a5
commit d90e8e4430
1 changed files with 14 additions and 5 deletions

View File

@ -46,15 +46,16 @@ client.on('messageCreate', async (message) => {
if (conversation.messages.length === 0) {
conversation.messages.push({ role: 'user', content: `You are the smartest AI and help with anything I ask. You are great at coding! When giving a list always use one line per item. My name is ${message.author.username}.` });
conversation.messages.push({ role: 'user', content: `My name is ${message.author.username}.` });
conversation.messages.push({ role: 'assistant', content: `Hello, ${message.author.username}.` });
conversation.messages.push({ role: 'assistant', content: `Hello, ${message.author.username}, how may I help you?` });
conversation.messages.push({ role: 'user', content: message.cleanContent });
} else {
// Append user message to conversation history
conversation.messages.push({ role: 'user', content: message.cleanContent });
}
if (message.content === '!reset') {
if (message.content === '!reset' || message.content === '!r') {
conversations.delete(userID); // Delete user's conversation map if they request reset
await message.channel.send('Conversation reset.');
return;
@ -71,12 +72,20 @@ client.on('messageCreate', async (message) => {
// Append bot message to conversation history
conversation.messages.push({ role: 'assistant', content: response });
await message.channel.send(response);
if (response && response.trim()) {
// Send response to user if it's not empty
await message.channel.send(response);
} 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
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?');
}
conversations.set(userID, conversation); // Update user's conversation map in memory
} catch (err) {
console.error(err);
await message.channel.send('Oops, something went wrong!');
await message.channel.send('Oops, something went wrong!\nYou can try !reset which will start a new session.');
} finally {
conversation.busy = false;
}