mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
update bard design
This commit is contained in:
parent
11b0512c01
commit
8fd752b9b0
3 changed files with 20 additions and 21 deletions
|
@ -2,7 +2,7 @@ const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
const { editOrReply } = require('../../../labscore/utils/message')
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
|
|
||||||
const { canUseLimitedTestCommands, isLimitedTestUser } = require('../../../labscore/utils/testing')
|
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 superagent = require('superagent')
|
||||||
const { iconPill, smallIconPill, icon } = require('../../../labscore/utils/markdown')
|
const { iconPill, smallIconPill, icon } = require('../../../labscore/utils/markdown')
|
||||||
|
@ -32,7 +32,7 @@ module.exports = {
|
||||||
|
|
||||||
let input = args.text;
|
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(args.prompt !== "") prompt = args.prompt
|
||||||
|
|
||||||
if(context.message.messageReference) {
|
if(context.message.messageReference) {
|
||||||
|
@ -45,20 +45,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let model = "chat-bison-001"
|
let model = "chat-bison-001"
|
||||||
let modelDisplay = ""
|
if(args.model && isLimitedTestUser(context.user)) model = args.model
|
||||||
if(args.model && isLimitedTestUser(context.user)){
|
|
||||||
model = args.model
|
|
||||||
modelDisplay = " " + smallIconPill("robot", model)
|
|
||||||
}
|
|
||||||
|
|
||||||
let temperature = "0.25"
|
let temperature = "0.25"
|
||||||
let temperatureDisplay = ""
|
if(args.temperature !== 0.25) temperature = parseFloat(args.temperature)
|
||||||
if(args.temperature !== 0.25){
|
|
||||||
temperature = parseFloat(args.temperature)
|
|
||||||
temperatureDisplay = " " + smallIconPill("example", temperature)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_bard", context, "Generating response..."))
|
await editOrReply(context, createEmbed("ai_bard", context, "Generating response..."))
|
||||||
|
|
||||||
|
@ -76,12 +67,12 @@ module.exports = {
|
||||||
let inputDisplay = args.text
|
let inputDisplay = args.text
|
||||||
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
||||||
|
|
||||||
let description = [smallIconPill("generative_ai", inputDisplay) + modelDisplay + temperatureDisplay, '']
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
if(!res.body.output) res.body.output = '[Empty Response]'
|
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 {
|
else {
|
||||||
files.push({
|
files.push({
|
||||||
filename: `chat.${Date.now().toString(36)}.txt`,
|
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||||
|
@ -90,11 +81,14 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return editOrReply(context, {
|
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(),
|
description: description.join('\n').substr(),
|
||||||
footer: {
|
footer: {
|
||||||
text: `This information may be inaccurate or biased • ${context.application.name}`,
|
text: `This information may be inaccurate or biased • ${context.application.name}`
|
||||||
iconUrl: STATICS.bard
|
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
files
|
files
|
||||||
|
|
|
@ -105,7 +105,7 @@ module.exports.createEmbed = function(type, context, content){
|
||||||
if(!content) embedTypes[type](context)
|
if(!content) embedTypes[type](context)
|
||||||
let emb = 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
|
emb.author.name = content
|
||||||
return emb
|
return emb
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ module.exports.createEmbed = function(type, context, content){
|
||||||
return emb
|
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(["image"].includes(type)){
|
||||||
if(content.url.includes('://')){
|
if(content.url.includes('://')){
|
||||||
|
|
|
@ -118,6 +118,10 @@ const Statics = Object.freeze({
|
||||||
file: "icons/core/ico_notice_bard_spark.gif",
|
file: "icons/core/ico_notice_bard_spark.gif",
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
|
ai_bard_idle: {
|
||||||
|
file: "icons/core/ico_notice_bard_idle.gif",
|
||||||
|
revision: 0
|
||||||
|
},
|
||||||
warning: {
|
warning: {
|
||||||
file: "icons/core/ico_notice_warning.png",
|
file: "icons/core/ico_notice_warning.png",
|
||||||
revision: 0
|
revision: 0
|
||||||
|
@ -165,5 +169,6 @@ module.exports.STATIC_ICONS = Object.freeze({
|
||||||
loading: staticAsset(Statics.icons.loading),
|
loading: staticAsset(Statics.icons.loading),
|
||||||
ai: staticAsset(Statics.icons.ai),
|
ai: staticAsset(Statics.icons.ai),
|
||||||
ai_bard: staticAsset(Statics.icons.ai_bard),
|
ai_bard: staticAsset(Statics.icons.ai_bard),
|
||||||
|
ai_bard_idle: staticAsset(Statics.icons.ai_bard_idle),
|
||||||
warning: staticAsset(Statics.icons.warning)
|
warning: staticAsset(Statics.icons.warning)
|
||||||
})
|
})
|
Loading…
Add table
Add a link
Reference in a new issue