mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 13:43:06 -04:00
privileged model override feature for gpt
This commit is contained in:
parent
9b1e76ebc3
commit
60a8158bff
2 changed files with 17 additions and 12 deletions
|
@ -18,21 +18,25 @@ module.exports = {
|
||||||
description_short: 'Chat with GPT-4o.',
|
description_short: 'Chat with GPT-4o.',
|
||||||
examples: ['gpt How many otter species are there?'],
|
examples: ['gpt How many otter species are there?'],
|
||||||
category: 'limited',
|
category: 'limited',
|
||||||
usage: 'gpt <input> [-prompt <prompt override>]'
|
usage: 'gpt <input> [-prompt <prompt override>] [-model <model identifier>]'
|
||||||
},
|
},
|
||||||
args: [
|
args: [
|
||||||
{ name: 'prompt', default: '', required: false, help: "The starting system prompt." },
|
{ name: 'prompt', default: '', required: false, help: "The starting system prompt." },
|
||||||
|
{ name: 'model', default: 'gpt-4o', required: false, help: "The model." },
|
||||||
// { name: 'temperature', default: 0.25, required: false, help: "Model temperature." },
|
// { name: 'temperature', default: 0.25, required: false, help: "Model temperature." },
|
||||||
],
|
],
|
||||||
permissionsClient: [...PERMISSION_GROUPS.baseline, ...PERMISSION_GROUPS.attachments],
|
permissionsClient: [...PERMISSION_GROUPS.baseline, ...PERMISSION_GROUPS.attachments],
|
||||||
run: async (context, args) => {
|
run: async (context, args) => {
|
||||||
if(!await hasFeature(context, "ai/gpt")) return;
|
if(!await hasFeature(context, "ai/gpt")) return;
|
||||||
await acknowledge(context);
|
await acknowledge(context);
|
||||||
|
|
||||||
|
let model = "gpt-4o"
|
||||||
|
if(args.model && await hasFeature(context, "ai/gpt/prompt")) model = args.model;
|
||||||
|
|
||||||
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`))
|
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`))
|
||||||
|
|
||||||
let input = args.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.`
|
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
|
if(args.prompt !== "") prompt = args.prompt
|
||||||
|
|
||||||
|
@ -41,12 +45,12 @@ module.exports = {
|
||||||
let msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId);
|
let msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId);
|
||||||
|
|
||||||
if(msg.content && msg.content.length) input = msg.content
|
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; }
|
else if(msg.embeds?.length) for(const e of msg.embeds) if(e[1].description?.length) { input = e[1].description; break; }
|
||||||
|
|
||||||
prompt = args.text
|
prompt = args.text
|
||||||
if(args.prompt !== "") return editOrReply(context, createEmbed("warning", context, `Prompt parameter is unsupported for message replies.`))
|
if(args.prompt !== "") return editOrReply(context, createEmbed("warning", context, `Prompt parameter is unsupported for message replies.`))
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("defaultNoFooter", context, {
|
await editOrReply(context, createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
|
@ -58,13 +62,13 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
let res = await gpt(context, prompt, input)
|
let res = await gpt(context, prompt, input, model)
|
||||||
res = res.response;
|
res = res.response;
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
if(!res.body.response) return editOrReply(context, createEmbed("error", context, `GPT-4o returned an error. Try again later.`))
|
if(!res.body.response) return editOrReply(context, createEmbed("error", context, `OpenAI returned an error. Try again later.`))
|
||||||
|
|
||||||
if(res.body.response.length <= 4000) description.push(res.body.response)
|
if(res.body.response.length <= 4000) description.push(res.body.response)
|
||||||
else {
|
else {
|
||||||
|
@ -82,7 +86,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
description: description.join('\n'),
|
description: description.join('\n'),
|
||||||
footer: {
|
footer: {
|
||||||
text: `GPT-4o • Response may be factually wrong or completely made up.`
|
text: `OpenAI${res.body.model.startsWith("gpt-4o") ? "" : ` (${res.body.model})`} • Response may be factually wrong or completely made up.`
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
files
|
files
|
||||||
|
|
|
@ -381,10 +381,11 @@ module.exports.garfield = async function(context,){
|
||||||
return await request(Api.UTILS_GARFIELD, "GET", {}, {})
|
return await request(Api.UTILS_GARFIELD, "GET", {}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.gpt = async function(context, prompt, input){
|
module.exports.gpt = async function(context, prompt, input, model = "gpt-4o"){
|
||||||
return await request(Api.UTILS_GPT, "GET", {}, {
|
return await request(Api.UTILS_GPT, "GET", {}, {
|
||||||
prompt,
|
prompt,
|
||||||
input
|
input,
|
||||||
|
model
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue