update bard design

This commit is contained in:
derpystuff 2023-10-10 17:59:34 +02:00
parent 11b0512c01
commit 8fd752b9b0
3 changed files with 20 additions and 21 deletions

View file

@ -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,19 +45,10 @@ 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

View file

@ -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('://')){

View file

@ -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)
})