bard upgrade

This commit is contained in:
derpystuff 2023-10-14 23:56:32 +02:00
parent aa50ca3411
commit 32ef0811ab
2 changed files with 108 additions and 27 deletions

View file

@ -12,13 +12,12 @@ const { Permissions } = require("detritus-client/lib/constants");
module.exports = {
name: 'bard',
label: 'text',
aliases: ['palm2'],
metadata: {
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nTalk to Bard.`,
description_short: 'Chat with Bard.',
examples: ['bard How many otter species are there?'],
category: 'limited',
usage: 'bard <input> [-prompt <prompt override>]'
usage: 'bard <input>'
},
args: [
{ name: 'prompt', default: '', required: false, help: "The starting system prompt." },
@ -32,26 +31,6 @@ module.exports = {
if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]})
let input = args.text;
let prompt = `You are a friendly chat bot designed to help people.\n- Today\'s date is ${new Date().toLocaleDateString('en-us', { weekday:"long", year:"numeric", month:"long", day:"numeric"})}\n- You should always use gender neutral pronouns when possible.\n- When answering a question, be concise and to the point.\n- Try to keep responses below 1000 characters. This does not apply to subjects that require more exhaustive or in-depth explanation.`
if(args.prompt !== "") prompt = args.prompt
// Get content if the user replies to anything
if(context.message.messageReference) {
let msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId);
if(msg.content && msg.content.length) input = msg.content
else if(msg.embeds?.length) for(const e of msg.embeds) if(e[1].description?.length) { input = e[1].description; break; }
prompt = args.text
if(args.prompt !== "") return editOrReply(context, {embeds:[createEmbed("warning", context, `Prompt parameter is unsupported for message replies.`)]})
}
let model = "chat-bison-001"
if(args.model && isLimitedTestUser(context.user)) model = args.model
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) + '...'
@ -59,15 +38,12 @@ module.exports = {
try{
await editOrReply(context, createEmbed("ai_bard", context, inputDisplay))
let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2`)
let res = await superagent.post(`${process.env.AI_SERVER}/google/bard`)
.set({
Authorization: process.env.AI_SERVER_KEY
})
.send({
prompt,
input: [input],
temperature,
model
input
})
let description = []