From cd5e9ceb4ac4bacca30bc9f296fa5ed484903f22 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Wed, 22 Nov 2023 16:02:57 +0100 Subject: [PATCH] fix palm --- commands/message/limited/bard.js | 5 +---- commands/message/limited/chat.js | 7 ++----- commands/message/limited/clyde.js | 7 ++----- commands/message/limited/dalle.js | 7 ++----- commands/message/limited/palm.js | 10 +++------- labscore/utils/markdown.js | 2 -- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/commands/message/limited/bard.js b/commands/message/limited/bard.js index 9f258c2..5149e28 100644 --- a/commands/message/limited/bard.js +++ b/commands/message/limited/bard.js @@ -28,9 +28,6 @@ module.exports = { if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`)) let input = args.text; - - let inputDisplay = args.text.replace(/\n/g, ' ') - if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' try{ await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard)) @@ -59,7 +56,7 @@ module.exports = { return editOrReply(context, { embeds:[createEmbed("defaultNoFooter", context, { author: { - name: inputDisplay, + name: stringwrap(args.text, 50), iconUrl: STATIC_ICONS.ai_bard_idle }, description: description.join('\n'), diff --git a/commands/message/limited/chat.js b/commands/message/limited/chat.js index 5e41bc1..ae2d73f 100644 --- a/commands/message/limited/chat.js +++ b/commands/message/limited/chat.js @@ -5,7 +5,7 @@ const { canUseLimitedTestCommands, isLimitedTestUser } = require('../../../labsc const { STATICS } = require('../../../labscore/utils/statics'); const superagent = require('superagent') -const { iconPill } = require('../../../labscore/utils/markdown') +const { iconPill, stringwrap } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); @@ -89,9 +89,6 @@ module.exports = { model: MODELS[model.toLowerCase()].id }) - let inputDisplay = args.text.replace(/\n/g, ' ') - if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' - let description = [] let files = []; @@ -109,7 +106,7 @@ module.exports = { embeds:[createEmbed("defaultNoFooter", context, { author: { iconUrl: MODELS[model.toLowerCase()].icon, - name: inputDisplay + name: stringwrap(args.text, 50) }, description: description.join('\n'), footer: { diff --git a/commands/message/limited/clyde.js b/commands/message/limited/clyde.js index 35f1118..ae0be13 100644 --- a/commands/message/limited/clyde.js +++ b/commands/message/limited/clyde.js @@ -5,7 +5,7 @@ const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing') const { STATIC_ICONS } = require('../../../labscore/utils/statics'); const superagent = require('superagent') -const { iconPill } = require('../../../labscore/utils/markdown') +const { iconPill, stringwrap } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); const { getUser } = require('../../../labscore/utils/users'); @@ -87,9 +87,6 @@ Current time: ${new Date().toLocaleDateString('en-us', { weekday:"long", year:"n model: "CHATGPT" }) - let inputDisplay = args.text.replace(/\n/g, ' ') - if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' - let description = [] let files = []; @@ -107,7 +104,7 @@ Current time: ${new Date().toLocaleDateString('en-us', { weekday:"long", year:"n embeds:[createEmbed("defaultNoFooter", context, { author: { iconUrl: STATIC_ICONS.ai_clyde_idle, - name: inputDisplay + name: stringwrap(args.text, 50) }, description: description.join('\n') })], diff --git a/commands/message/limited/dalle.js b/commands/message/limited/dalle.js index 3c8ffd9..58d1ad6 100644 --- a/commands/message/limited/dalle.js +++ b/commands/message/limited/dalle.js @@ -5,7 +5,7 @@ const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing') const { STATICS } = require('../../../labscore/utils/statics'); const superagent = require('superagent') -const { iconPill, smallIconPill } = require('../../../labscore/utils/markdown') +const { iconPill, smallIconPill, stringwrap } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); @@ -41,10 +41,7 @@ module.exports = { // Fetch the image let img = await superagent.get(res.body.output) - let inputDisplay = args.text - if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' - - let description = [smallIconPill("generative_ai", inputDisplay), ''] + let description = [smallIconPill("generative_ai", stringwrap(args.text, 50)), ''] let files = []; if(!res.body.output) res.body.output = '[Empty Response]' diff --git a/commands/message/limited/palm.js b/commands/message/limited/palm.js index 9c89740..410da6a 100644 --- a/commands/message/limited/palm.js +++ b/commands/message/limited/palm.js @@ -5,7 +5,7 @@ const { canUseLimitedTestCommands, isLimitedTestUser } = require('../../../labsc const { STATIC_ICONS } = require('../../../labscore/utils/statics'); const superagent = require('superagent') -const { iconPill } = require('../../../labscore/utils/markdown') +const { iconPill, stringwrap } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); @@ -53,13 +53,10 @@ module.exports = { let temperature = "0.25" if(args.temperature !== 0.25) temperature = parseFloat(args.temperature) - let inputDisplay = args.text.replace(/\n/g, ' ') - if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' - try{ await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_palm_idle)) - let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2`) + let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2/chat`) .set({ Authorization: process.env.AI_SERVER_KEY }) @@ -86,7 +83,7 @@ module.exports = { return editOrReply(context, { embeds:[createEmbed("defaultNoFooter", context, { author: { - name: inputDisplay, + name: stringwrap(prompt, 50), iconUrl: STATIC_ICONS.ai_palm_idle }, description: description.join('\n'), @@ -98,7 +95,6 @@ module.exports = { }) }catch(e){ if(e.response.body?.message) return editOrReply(context, createEmbed("warning", context, e.response.body.message)) - console.log(e) return editOrReply(context, createEmbed("error", context, `Unable to generate text.`)) } } diff --git a/labscore/utils/markdown.js b/labscore/utils/markdown.js index 9b36382..b19c5a1 100644 --- a/labscore/utils/markdown.js +++ b/labscore/utils/markdown.js @@ -30,8 +30,6 @@ module.exports.timestamp = function(time, flag = "t"){ } module.exports.stringwrap = function(content = "", length){ - console.log(content) - console.log(length) if(content.length > length) return content.substr(0, length) + '...'; return content; }