fixing creating a new chat
This commit is contained in:
parent
e08e8f6f93
commit
02e28978c6
@ -2,25 +2,35 @@ const { EmbedBuilder } = require('discord.js');
|
|||||||
var unirest = require('unirest');
|
var unirest = require('unirest');
|
||||||
const jsonfile = require('jsonfile')
|
const jsonfile = require('jsonfile')
|
||||||
|
|
||||||
|
var apiUrl = `http://${process.env.INTERNAL_IP}:8008/api/chat/`;
|
||||||
|
var model = 'gpt4all';
|
||||||
|
var temperature = 0.1;
|
||||||
|
var topK = 50;
|
||||||
|
var topP = 0.95;
|
||||||
|
var maxLength = 256;
|
||||||
|
var contextWindow = 512;
|
||||||
|
var repeatLastN = 64;
|
||||||
|
var repeatPenalty = 1.3;
|
||||||
|
var initPrompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request. The response must be accurate, concise and evidence-based whenever possible. A complete answer is always ended by [end of text].';
|
||||||
|
var nThreads = 7;
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "create-session",
|
name: "create-session",
|
||||||
description: "create a new session chat",
|
description: "create a new session chat",
|
||||||
private: true,
|
private: true,
|
||||||
run: async (client, interaction) => {
|
run: async (client, interaction) => {
|
||||||
const file = './cache/' + interaction.user.id
|
const file = './cache/' + interaction.user.id
|
||||||
|
console.log("DEBUG: " + apiUrl + '?model=' + model + '&temperature=' + temperature + '&top_k=' + topK + '&top_p=' + topP + '&max_length=' + maxLength + '&context_window=' + contextWindow + '&repeat_last_n=' + repeatLastN + '&repeat_penalty=' + repeatPenalty + '&init_prompt=' + initPrompt + '&n_threads=' + nThreads)
|
||||||
// The Auth stuff here is internal to my set up only and may be removed if you use this bot.
|
var req = unirest('POST', apiUrl + '?model=' + model + '&temperature=' + temperature + '&top_k=' + topK + '&top_p=' + topP + '&max_length=' + maxLength + '&context_window=' + contextWindow + '&repeat_last_n=' + repeatLastN + '&repeat_penalty=' + repeatPenalty + '&init_prompt=' + initPrompt + '&n_threads=' + nThreads)
|
||||||
// My chat GUI for Serge is locked down by basic auth in apache to safe guard from
|
.headers({
|
||||||
// Users issuing mulitple jobs at a time until there is some built in way to do so.
|
'accept': 'application/json'
|
||||||
unirest
|
|
||||||
.post(`https://${process.env.PUBLIC_URL}/api/chat`)
|
|
||||||
.headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' })
|
|
||||||
.auth({
|
|
||||||
user: process.env.USERNAME,
|
|
||||||
pass: process.env.PASS,
|
|
||||||
sendImmediately: true
|
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.send('')
|
||||||
|
.end(function (response) {
|
||||||
|
console.log(response.body);
|
||||||
|
|
||||||
|
|
||||||
const obj = { id: response.body }
|
const obj = { id: response.body }
|
||||||
|
|
||||||
jsonfile.writeFile(file, obj, function (err) {
|
jsonfile.writeFile(file, obj, function (err) {
|
||||||
@ -34,6 +44,8 @@ module.exports = {
|
|||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
interaction.followUp({ embeds: [embed] });
|
interaction.followUp({ embeds: [embed] });
|
||||||
})
|
|
||||||
},
|
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user