better name for session ID where needed and better formatting
This commit is contained in:
parent
f34805479d
commit
ebf1d675f1
@ -3,7 +3,7 @@ const axios = require('axios');
|
|||||||
const jsonfile = require('jsonfile');
|
const jsonfile = require('jsonfile');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const readFile = util.promisify(jsonfile.readFile);
|
const readFile = util.promisify(jsonfile.readFile);
|
||||||
let session2;
|
let sessionID;
|
||||||
let isProcessing = false; // Semaphore variable
|
let isProcessing = false; // Semaphore variable
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -30,9 +30,9 @@ module.exports = {
|
|||||||
try {
|
try {
|
||||||
const session = await readFile(file);
|
const session = await readFile(file);
|
||||||
|
|
||||||
session2 = session.id;
|
sessionID = session.id;
|
||||||
|
|
||||||
if (!session2) {
|
if (!sessionID) {
|
||||||
console.log("No Session!");
|
console.log("No Session!");
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
return;
|
return;
|
||||||
@ -41,10 +41,10 @@ module.exports = {
|
|||||||
let prompt = interaction.options._hoistedOptions[0].value.replace(" ", "+");
|
let prompt = interaction.options._hoistedOptions[0].value.replace(" ", "+");
|
||||||
const headers = {
|
const headers = {
|
||||||
'authority': process.env.PUBLIC_URL,
|
'authority': process.env.PUBLIC_URL,
|
||||||
'accept': 'text/event-stream',
|
'accept': 'text',
|
||||||
};
|
};
|
||||||
console.log(session);
|
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
|
headers
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const jsonfile = require('jsonfile');
|
const jsonfile = require('jsonfile');
|
||||||
let session2;
|
let sessionID;
|
||||||
|
|
||||||
function parseQuestionsAndAnswers(jsonStr) {
|
function parseQuestionsAndAnswers(jsonStr) {
|
||||||
const obj = JSON.parse(jsonStr);
|
const obj = JSON.parse(jsonStr);
|
||||||
@ -19,9 +19,9 @@ module.exports = {
|
|||||||
|
|
||||||
if (err) return interaction.editReply('Please create a session using /create-session.');
|
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!");
|
console.log("No Session!");
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
return;
|
return;
|
||||||
@ -30,7 +30,7 @@ module.exports = {
|
|||||||
'authority': process.env.PUBLIC_URL,
|
'authority': process.env.PUBLIC_URL,
|
||||||
'accept': 'text/event-stream',
|
'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,
|
headers,
|
||||||
auth: {
|
auth: {
|
||||||
username: process.env.USERNAME,
|
username: process.env.USERNAME,
|
||||||
|
Loading…
Reference in New Issue
Block a user