diff --git a/llamabot.js b/llamabot.js index 3f3365e..5a7d7d4 100644 --- a/llamabot.js +++ b/llamabot.js @@ -72,7 +72,7 @@ client.on('messageCreate', async (message) => { }); conversation.messages.push({ role: 'assistant', - content: `Hello, ${message.author.username}, how may I help you?` + content: `Hello, ${message.author.username}, I am here to answer any question you have, how may I help you?` }); conversation.messages.push({ role: 'user', @@ -139,6 +139,8 @@ async function generateResponse(conversation) { controller.abort(); }, 900000); + const messagesCopy = [...conversation.messages]; // create a copy of the messages array + try { const response = await fetch(`http://${process.env.ROOT_IP}:${process.env.ROOT_PORT}/v1/chat/completions`, { method: 'POST', @@ -147,7 +149,7 @@ async function generateResponse(conversation) { 'Content-Type': 'application/json' }, body: JSON.stringify({ - messages: conversation.messages + messages: messagesCopy // use the copy of the messages array }), signal: controller.signal }); @@ -163,8 +165,7 @@ async function generateResponse(conversation) { return sanitizedResponse; } catch (err) { - console.error(err); - return 'Oops, something went wrong!'; + throw err; } finally { clearTimeout(timeout); }