This commit is contained in:
Lukian LEIZOUR 2023-03-02 20:18:22 +01:00
parent 614b7afc08
commit 36a0e6a872
2 changed files with 19 additions and 11 deletions

11
app.js
View file

@ -154,7 +154,15 @@ client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
if (interaction.commandName === 'gptrequest') { if (interaction.commandName === 'gptrequest') {
interaction.deferReply();
answerQuestion(interaction.options.get('question').value).then((res) => { answerQuestion(interaction.options.get('question').value).then((res) => {
if (res.data.choices[0].message.content.length > 4096) {
interaction.reply(res.data.choices[0].message.content.lenght);
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
}
else{
const embed = new discord.EmbedBuilder() const embed = new discord.EmbedBuilder()
.setColor(0xFABBDE) .setColor(0xFABBDE)
.setAuthor({ name : "Reply to : " + interaction.member.user.username, iconURL : "https://cdn.discordapp.com/avatars/"+interaction.member.user.id+"/"+interaction.member.user.avatar+".jpeg"}) .setAuthor({ name : "Reply to : " + interaction.member.user.username, iconURL : "https://cdn.discordapp.com/avatars/"+interaction.member.user.id+"/"+interaction.member.user.avatar+".jpeg"})
@ -164,7 +172,8 @@ client.on('interactionCreate', async interaction => {
console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value); console.log('[Discord] Sent answer to : ' + interaction.options.get('question').value);
addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value); addToLogs('[Discord] Sent answer to : ' +interaction.options.get('question').value);
interaction.reply({ embeds : [embed] }); interaction.editReply({ embeds : [embed] });
}
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err);
addToLogs(err); addToLogs(err);

View file

@ -25,7 +25,6 @@ async function answerQuestion(query) {
response = await openai.createChatCompletion({ response = await openai.createChatCompletion({
model: "gpt-3.5-turbo", model: "gpt-3.5-turbo",
messages: [{ "role" : "user", "content" : query}], messages: [{ "role" : "user", "content" : query}],
max_tokens: 500,
temperature: 0.9, temperature: 0.9,
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err);