better name for session ID where needed and better formatting

This commit is contained in:
Raven Scott 2023-03-26 02:27:33 +02:00
parent f34805479d
commit ebf1d675f1
2 changed files with 9 additions and 9 deletions

View File

@ -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
});

View File

@ -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,