From 8fd752b9b08b369673ff0282b6f0c3c7c5a9db73 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Tue, 10 Oct 2023 17:59:34 +0200 Subject: [PATCH] update bard design --- commands/message/fun/bard.js | 32 +++++++++++++------------------- labscore/utils/embed.js | 4 ++-- labscore/utils/statics.js | 5 +++++ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/commands/message/fun/bard.js b/commands/message/fun/bard.js index 57b0350..f9386fc 100644 --- a/commands/message/fun/bard.js +++ b/commands/message/fun/bard.js @@ -2,7 +2,7 @@ const { createEmbed } = require('../../../labscore/utils/embed') const { editOrReply } = require('../../../labscore/utils/message') const { canUseLimitedTestCommands, isLimitedTestUser } = require('../../../labscore/utils/testing') -const { STATICS } = require('../../../labscore/utils/statics'); +const { STATICS, STATIC_ICONS } = require('../../../labscore/utils/statics'); const superagent = require('superagent') const { iconPill, smallIconPill, icon } = require('../../../labscore/utils/markdown') @@ -32,7 +32,7 @@ module.exports = { let input = args.text; - let prompt = 'You are a friendly chat bot designed to help people. You should always use gender neutral pronouns when possible.' + let prompt = 'You are a friendly chat bot designed to help people.\n- You should always use gender neutral pronouns when possible.\n- Try to keep your responses under 2000 characters. This isn\'t required for more detailed answers.' if(args.prompt !== "") prompt = args.prompt if(context.message.messageReference) { @@ -45,20 +45,11 @@ module.exports = { } let model = "chat-bison-001" - let modelDisplay = "" - if(args.model && isLimitedTestUser(context.user)){ - model = args.model - modelDisplay = " " + smallIconPill("robot", model) - } + if(args.model && isLimitedTestUser(context.user)) model = args.model let temperature = "0.25" - let temperatureDisplay = "" - if(args.temperature !== 0.25){ - temperature = parseFloat(args.temperature) - temperatureDisplay = " " + smallIconPill("example", temperature) - } + if(args.temperature !== 0.25) temperature = parseFloat(args.temperature) - try{ await editOrReply(context, createEmbed("ai_bard", context, "Generating response...")) @@ -76,12 +67,12 @@ module.exports = { let inputDisplay = args.text if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...' - let description = [smallIconPill("generative_ai", inputDisplay) + modelDisplay + temperatureDisplay, ''] + let description = [] let files = []; if(!res.body.output) res.body.output = '[Empty Response]' - - if(res.body.output.length <= 2000) description.push(res.body.output.substr(0, 2000 - args.text.length)) + + if(res.body.output.length <= 2000) description.push(res.body.output) else { files.push({ filename: `chat.${Date.now().toString(36)}.txt`, @@ -90,11 +81,14 @@ module.exports = { } return editOrReply(context, { - embeds:[createEmbed("default", context, { + embeds:[createEmbed("defaultNoFooter", context, { + author: { + name: inputDisplay, + iconUrl: STATIC_ICONS.ai_bard_idle + }, description: description.join('\n').substr(), footer: { - text: `This information may be inaccurate or biased • ${context.application.name}`, - iconUrl: STATICS.bard + text: `This information may be inaccurate or biased • ${context.application.name}` } })], files diff --git a/labscore/utils/embed.js b/labscore/utils/embed.js index 33c8d69..e574581 100644 --- a/labscore/utils/embed.js +++ b/labscore/utils/embed.js @@ -105,7 +105,7 @@ module.exports.createEmbed = function(type, context, content){ if(!content) embedTypes[type](context) let emb = embedTypes[type](context) - if(["success","warning","error","loading","ai"].includes(type)){ + if(["success","warning","error","loading","ai","ai_bard"].includes(type)){ emb.author.name = content return emb } @@ -116,7 +116,7 @@ module.exports.createEmbed = function(type, context, content){ return emb } - if(content && content.footer && !content.footer.iconUrl) content.footer.iconUrl = STATICS.labscore + if(content && content.footer && !content.footer.iconUrl && type !== "defaultNoFooter") content.footer.iconUrl = STATICS.labscore if(["image"].includes(type)){ if(content.url.includes('://')){ diff --git a/labscore/utils/statics.js b/labscore/utils/statics.js index 0aa274c..f0f83c1 100644 --- a/labscore/utils/statics.js +++ b/labscore/utils/statics.js @@ -118,6 +118,10 @@ const Statics = Object.freeze({ file: "icons/core/ico_notice_bard_spark.gif", revision: 0 }, + ai_bard_idle: { + file: "icons/core/ico_notice_bard_idle.gif", + revision: 0 + }, warning: { file: "icons/core/ico_notice_warning.png", revision: 0 @@ -165,5 +169,6 @@ module.exports.STATIC_ICONS = Object.freeze({ loading: staticAsset(Statics.icons.loading), ai: staticAsset(Statics.icons.ai), ai_bard: staticAsset(Statics.icons.ai_bard), + ai_bard_idle: staticAsset(Statics.icons.ai_bard_idle), warning: staticAsset(Statics.icons.warning) }) \ No newline at end of file