From 0f507fb98a60b3474a5a799724f1fd49b1dad56a Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 3 Apr 2023 03:11:54 +0200 Subject: [PATCH] Better Logging --- commands/system/chat.js | 2 +- commands/system/new-chat.js | 13 ++++++++----- commands/system/view-session-history.js | 4 +--- events/interactionCreate.js | 1 - 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/system/chat.js b/commands/system/chat.js index c0ae79c..bfe9840 100644 --- a/commands/system/chat.js +++ b/commands/system/chat.js @@ -51,7 +51,7 @@ module.exports = { headers }); - console.log(response.data.answer); + console.log(`Prompt: ${prompt.replace("+", " ")}\nResponse: ${response.data.answer}`); interaction.editReply(response.data.answer); } catch (err) { diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 90a16aa..138d95a 100644 --- a/commands/system/new-chat.js +++ b/commands/system/new-chat.js @@ -52,6 +52,8 @@ module.exports = { ], run: async (client, interaction) => { + + console.log(`--- ${interaction.user.id} has requested a new session! ---`) const file = './cache/' + interaction.user.id let options = interaction.options._hoistedOptions; @@ -85,6 +87,7 @@ module.exports = { console.log("-- No init-prompt provided, using default --"); } else { initPrompt = userInputInitPrompt; + console.log(`User set initPrompt to ${initPrompt}`) } // Modal Setting @@ -93,6 +96,7 @@ module.exports = { } else { if (modelList.includes(userInputModel)) { model = userInputModel; + console.log(`User set initPrompt to ${model}`) } else { let modelListStr = modelList.join(", "); return interaction.followUp(`You may only use one of the following: ${modelListStr}`); @@ -107,6 +111,8 @@ module.exports = { if (parsedTemperature >= 0.1 && parsedTemperature <= 2) { // temperature is within range temperature = parsedTemperature; + console.log(`User set temperature to ${temperature}`) + } else { // temperature is outside of range return interaction.followUp(`Temperature must be between 0.1 and 2`); @@ -121,6 +127,7 @@ module.exports = { if (parsedRepeatPenalty >= 0.1 && parsedRepeatPenalty <= 2) { // RepeatPenalty is within range repeatPenalty = parsedRepeatPenalty; + console.log(`User set repeatPenalty to ${repeatPenalty}`) } else { // RepeatPenalty is outside of range return interaction.followUp(`Repeat Penalty must be between 0.1 and 2`); @@ -133,9 +140,6 @@ module.exports = { }) .send('') .end(function (response) { - console.log(response.body); - - const obj = { id: response.body } jsonfile.writeFile(file, obj, function (err) { @@ -149,8 +153,7 @@ module.exports = { .setTimestamp() .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); interaction.followUp({ embeds: [embed] }); - - + console.log(`--- Session created for ${interaction.user.id} ---`) }); } }; \ No newline at end of file diff --git a/commands/system/view-session-history.js b/commands/system/view-session-history.js index aff7bc4..141f745 100644 --- a/commands/system/view-session-history.js +++ b/commands/system/view-session-history.js @@ -41,9 +41,7 @@ module.exports = { password: process.env.PASS } }); - - console.log(response.data) - + if (!response.data.questions) return interaction.editReply("You have no history in this session yet :) "); const result = parseQuestionsAndAnswers(JSON.stringify(response.data)); diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 85b0c04..6546bee 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -49,7 +49,6 @@ client.on("interactionCreate", async (interaction) => { let parsedData = JSON.parse(dataToProcess) // If the command is private, set ephemeral true else, set false - console.log(parsedData) if (parsedData.private == true) { await interaction.deferReply({ ephemeral: true