From ebf1d675f1af978bddd97f6d1693fd0788a6fa42 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sun, 26 Mar 2023 02:27:33 +0200 Subject: [PATCH] better name for session ID where needed and better formatting --- commands/system/chat.js | 10 +++++----- commands/system/view-session-history.js | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/system/chat.js b/commands/system/chat.js index e9573f0..a4a9e5a 100644 --- a/commands/system/chat.js +++ b/commands/system/chat.js @@ -3,7 +3,7 @@ const axios = require('axios'); const jsonfile = require('jsonfile'); const util = require('util'); const readFile = util.promisify(jsonfile.readFile); -let session2; +let sessionID; let isProcessing = false; // Semaphore variable module.exports = { @@ -30,9 +30,9 @@ module.exports = { try { const session = await readFile(file); - session2 = session.id; + sessionID = session.id; - if (!session2) { + if (!sessionID) { console.log("No Session!"); isProcessing = false; return; @@ -41,10 +41,10 @@ module.exports = { let prompt = interaction.options._hoistedOptions[0].value.replace(" ", "+"); const headers = { 'authority': process.env.PUBLIC_URL, - 'accept': 'text/event-stream', + 'accept': 'text', }; console.log(session); - const response = await axios.post(`http://${process.env.INTERNAL_IP}:8008/api/chat/` + session2 + '/question?prompt=' + prompt, { + const response = await axios.post(`http://${process.env.INTERNAL_IP}:8008/api/chat/${sessionID}/question?prompt=${prompt}`, { headers }); diff --git a/commands/system/view-session-history.js b/commands/system/view-session-history.js index 669f9d4..edeb283 100644 --- a/commands/system/view-session-history.js +++ b/commands/system/view-session-history.js @@ -1,6 +1,6 @@ const axios = require('axios'); const jsonfile = require('jsonfile'); -let session2; +let sessionID; function parseQuestionsAndAnswers(jsonStr) { const obj = JSON.parse(jsonStr); @@ -19,9 +19,9 @@ module.exports = { if (err) return interaction.editReply('Please create a session using /create-session.'); - session2 = session.id; + sessionID = session.id; - if (!session2) { + if (!sessionID) { console.log("No Session!"); isProcessing = false; return; @@ -30,7 +30,7 @@ module.exports = { 'authority': process.env.PUBLIC_URL, 'accept': 'text/event-stream', }; - const response = await axios.get(`http://${process.env.INTERNAL_IP}:8008/api/chat/` + session2, { + const response = await axios.get(`http://${process.env.INTERNAL_IP}:8008/api/chat/${sessionID}`, { headers, auth: { username: process.env.USERNAME,