mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 22:23:03 -04:00
rebrand
This commit is contained in:
parent
087583d9ce
commit
528baecb1d
4 changed files with 194 additions and 193 deletions
|
@ -1,159 +0,0 @@
|
||||||
const { createEmbed } = require('../../../labscore/utils/embed')
|
|
||||||
const { editOrReply } = require('../../../labscore/utils/message')
|
|
||||||
|
|
||||||
const { STATIC_ICONS } = require('../../../labscore/utils/statics');
|
|
||||||
|
|
||||||
const superagent = require('superagent')
|
|
||||||
const { iconPill, stringwrap } = require('../../../labscore/utils/markdown')
|
|
||||||
|
|
||||||
const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
|
||||||
const { Components } = require('detritus-client/lib/utils');
|
|
||||||
const { LlmPrivateBard } = require('../../../labscore/api/obelisk');
|
|
||||||
const { hasFeature } = require('../../../labscore/utils/testing');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: 'bard',
|
|
||||||
label: 'text',
|
|
||||||
metadata: {
|
|
||||||
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nChat with <:bard:1163200801871765504> Bard.`,
|
|
||||||
description_short: 'Chat with Bard.',
|
|
||||||
examples: ['bard How many otter species are there?'],
|
|
||||||
category: 'limited',
|
|
||||||
usage: 'bard <input>'
|
|
||||||
},
|
|
||||||
args: [],
|
|
||||||
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
|
|
||||||
run: async (context, args) => {
|
|
||||||
if(!await hasFeature(context, "ai/bard")) return;
|
|
||||||
|
|
||||||
context.triggerTyping();
|
|
||||||
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`))
|
|
||||||
|
|
||||||
let input = args.text;
|
|
||||||
|
|
||||||
try{
|
|
||||||
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
|
||||||
|
|
||||||
let res = await LlmPrivateBard(context, input)
|
|
||||||
res = res.response
|
|
||||||
|
|
||||||
let description = []
|
|
||||||
let files = [];
|
|
||||||
|
|
||||||
if(!res.body.candidates) return editOrReply(context, createEmbed("error", context, `Bard returned an error. Try again later.`))
|
|
||||||
|
|
||||||
if(res.body.candidates[0].length <= 4000) description.push(res.body.candidates[0])
|
|
||||||
else {
|
|
||||||
files.push({
|
|
||||||
filename: `chat.${Date.now().toString(36)}.txt`,
|
|
||||||
value: Buffer.from(res.body.candidates[0])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!res.body.candidates || res.body.candidates?.length <= 1) return editOrReply(context, {
|
|
||||||
embeds:[createEmbed("defaultNoFooter", context, {
|
|
||||||
author: {
|
|
||||||
name: stringwrap(args.text, 50, false),
|
|
||||||
iconUrl: STATIC_ICONS.ai_bard_idle
|
|
||||||
},
|
|
||||||
description: description.join('\n'),
|
|
||||||
footer: {
|
|
||||||
text: `Bard • Generative AI is experimental. Response may be factually wrong or completely made up.`
|
|
||||||
}
|
|
||||||
})],
|
|
||||||
files
|
|
||||||
})
|
|
||||||
// Draft support
|
|
||||||
else {
|
|
||||||
|
|
||||||
let currentView;
|
|
||||||
|
|
||||||
const components = new Components({
|
|
||||||
timeout: 100000,
|
|
||||||
run: async (ctx) => {
|
|
||||||
if (ctx.userId !== context.userId) return await ctx.respond(InteractionCallbackTypes.DEFERRED_UPDATE_MESSAGE);
|
|
||||||
|
|
||||||
// this sucks but works, ensures the newly selected option stays selected
|
|
||||||
for (let i = 0; i < components.components[0].components[0].options.length; i++) {
|
|
||||||
components.components[0].components[0].options[i].default = (components.components[0].components[0].options[i].value == ctx.data.values[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
draft = res.body.candidates[parseInt(ctx.data.values[0].replace('draft-', ''))]
|
|
||||||
|
|
||||||
description = []
|
|
||||||
files = [];
|
|
||||||
|
|
||||||
if(draft.length <= 4000) description.push(draft)
|
|
||||||
else {
|
|
||||||
files.push({
|
|
||||||
filename: `chat.${Date.now().toString(36)}.txt`,
|
|
||||||
value: Buffer.from(draft)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
currentView = createEmbed("defaultNoFooter", context, {
|
|
||||||
author: {
|
|
||||||
name: stringwrap(args.text, 50, false),
|
|
||||||
iconUrl: STATIC_ICONS.ai_bard_idle
|
|
||||||
},
|
|
||||||
description: description.join('\n'),
|
|
||||||
footer: {
|
|
||||||
text: `Bard • Generative AI is experimental. Response may be factually wrong or completely made up.`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await ctx.editOrRespond({
|
|
||||||
embeds:[currentView],
|
|
||||||
files,
|
|
||||||
components
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
let draftOptions = [];
|
|
||||||
for (let i = 0; i < res.body.candidates.length; i++) {
|
|
||||||
draftOptions.push({
|
|
||||||
label: `Draft ${i + 1}: ${stringwrap(res.body.candidates[i], 50, false)}`,
|
|
||||||
value: "draft-" + (i),
|
|
||||||
default: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
components.addSelectMenu({
|
|
||||||
placeholder: "View other drafts",
|
|
||||||
customId: "bard-drafts",
|
|
||||||
options: draftOptions
|
|
||||||
})
|
|
||||||
|
|
||||||
setTimeout(()=>{
|
|
||||||
editOrReply(context, {
|
|
||||||
embeds:[currentView],
|
|
||||||
components:[]
|
|
||||||
})
|
|
||||||
}, 100000)
|
|
||||||
|
|
||||||
currentView = createEmbed("defaultNoFooter", context, {
|
|
||||||
author: {
|
|
||||||
name: stringwrap(args.text, 50, false),
|
|
||||||
iconUrl: STATIC_ICONS.ai_bard_idle
|
|
||||||
},
|
|
||||||
description: description.join('\n'),
|
|
||||||
footer: {
|
|
||||||
text: `Bard • Generative AI is experimental. Response may be factually wrong or completely made up.`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return editOrReply(context, {
|
|
||||||
embeds:[currentView],
|
|
||||||
files,
|
|
||||||
components
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}catch(e){
|
|
||||||
if(e.response?.body?.message) return editOrReply(context, createEmbed("warning", context, e.response.body.message))
|
|
||||||
|
|
||||||
console.log(e)
|
|
||||||
return editOrReply(context, createEmbed("error", context, `Unable to generate response.`))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
70
commands/message/genai/gemini-pro.js
Normal file
70
commands/message/genai/gemini-pro.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
const { gemini, LlmModelsGenerate } = require("../../../labscore/api/obelisk");
|
||||||
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
|
||||||
|
const { STATIC_ICONS } = require("../../../labscore/utils/statics");
|
||||||
|
const { stringwrap, iconPill, smallIconPill } = require("../../../labscore/utils/markdown");
|
||||||
|
const { hasFeature } = require("../../../labscore/utils/testing");
|
||||||
|
module.exports = {
|
||||||
|
name: 'gemini-pro',
|
||||||
|
label: 'text',
|
||||||
|
aliases: ['gpro'],
|
||||||
|
metadata: {
|
||||||
|
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n${smallIconPill("reply", "Supports Replies")}\n\nRun Gemini 1.0 Pro with a custom prompt.`,
|
||||||
|
description_short: 'Gemini-1.0-Pro',
|
||||||
|
examples: ['gem why do they call it oven when you of in the cold food of out hot eat the food'],
|
||||||
|
category: 'limited',
|
||||||
|
usage: 'gemini-pro <prompt>'
|
||||||
|
},
|
||||||
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
|
||||||
|
run: async (context, args) => {
|
||||||
|
if(!await hasFeature(context, "ai/gemini/text")) return;
|
||||||
|
context.triggerTyping();
|
||||||
|
|
||||||
|
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (text).`))
|
||||||
|
|
||||||
|
let input = args.text;
|
||||||
|
|
||||||
|
try{
|
||||||
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_gemini))
|
||||||
|
|
||||||
|
let res = await LlmModelsGenerate(context, "gemini-1.5-pro", input, "BLOCK_NONE")
|
||||||
|
|
||||||
|
let description = []
|
||||||
|
let files = [];
|
||||||
|
|
||||||
|
if(res.response.body.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
||||||
|
|
||||||
|
let output = res.response.body.candidates[0]?.output
|
||||||
|
if(!output) return editOrReply(context, createEmbed("error", context, `Gemini returned an error. Try again later.`))
|
||||||
|
|
||||||
|
if(output.length <= 4000) description.push(output)
|
||||||
|
else {
|
||||||
|
files.push({
|
||||||
|
filename: `gemini.${Date.now().toString(36)}.txt`,
|
||||||
|
value: Buffer.from(output)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds:[createEmbed("defaultNoFooter", context, {
|
||||||
|
author: {
|
||||||
|
name: stringwrap(input, 50, false),
|
||||||
|
iconUrl: STATIC_ICONS.ai_gemini
|
||||||
|
},
|
||||||
|
description: description.join('\n'),
|
||||||
|
footer: {
|
||||||
|
text: `Generative AI is experimental • Data submitted to Gemini may be used by Google for training.`
|
||||||
|
}
|
||||||
|
})],
|
||||||
|
files
|
||||||
|
})
|
||||||
|
} catch(e){
|
||||||
|
console.log(e)
|
||||||
|
if(e.response?.body?.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
||||||
|
return editOrReply(context, createEmbed("error", context, `Unable to generate response.`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,69 +1,159 @@
|
||||||
const { gemini, LlmModelsGenerate } = require("../../../labscore/api/obelisk");
|
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
const { editOrReply } = require("../../../labscore/utils/message");
|
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { STATIC_ICONS } = require('../../../labscore/utils/statics');
|
||||||
|
|
||||||
|
const superagent = require('superagent')
|
||||||
|
const { iconPill, stringwrap } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
|
const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
||||||
|
const { Components } = require('detritus-client/lib/utils');
|
||||||
|
const { LlmPrivateBard } = require('../../../labscore/api/obelisk');
|
||||||
|
const { hasFeature } = require('../../../labscore/utils/testing');
|
||||||
|
|
||||||
const { STATIC_ICONS } = require("../../../labscore/utils/statics");
|
|
||||||
const { stringwrap, iconPill, smallIconPill } = require("../../../labscore/utils/markdown");
|
|
||||||
const { hasFeature } = require("../../../labscore/utils/testing");
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'gemini',
|
name: 'gemini',
|
||||||
label: 'text',
|
label: 'text',
|
||||||
aliases: ['gem'],
|
aliases: ["bard","gem"],
|
||||||
metadata: {
|
metadata: {
|
||||||
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n${smallIconPill("reply", "Supports Replies")}\n\nRun Gemini Pro with a custom prompt.`,
|
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nChat with <:icoext_gemini:1240316089515249715> Gemini.`,
|
||||||
description_short: 'Gemini',
|
description_short: 'Chat with Gemini.',
|
||||||
examples: ['gem why do they call it oven when you of in the cold food of out hot eat the food'],
|
examples: ['gemini How many otter species are there?'],
|
||||||
category: 'limited',
|
category: 'limited',
|
||||||
usage: 'gemini <prompt>'
|
usage: 'gemini <input>'
|
||||||
},
|
},
|
||||||
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
|
args: [],
|
||||||
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
|
||||||
run: async (context, args) => {
|
run: async (context, args) => {
|
||||||
if(!await hasFeature(context, "ai/gemini/text")) return;
|
if(!await hasFeature(context, "ai/bard")) return;
|
||||||
context.triggerTyping();
|
|
||||||
|
|
||||||
|
context.triggerTyping();
|
||||||
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;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_gemini))
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
||||||
|
|
||||||
let res = await LlmModelsGenerate(context, "gemini-1.5-pro", input, "BLOCK_NONE")
|
let res = await LlmPrivateBard(context, input)
|
||||||
|
res = res.response
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
if(res.response.body.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
if(!res.body.candidates) return editOrReply(context, createEmbed("error", context, `Bard returned an error. Try again later.`))
|
||||||
|
|
||||||
let output = res.response.body.candidates[0]?.output
|
if(res.body.candidates[0].length <= 4000) description.push(res.body.candidates[0])
|
||||||
if(!output) return editOrReply(context, createEmbed("error", context, `Gemini returned an error. Try again later.`))
|
|
||||||
|
|
||||||
if(output.length <= 4000) description.push(output)
|
|
||||||
else {
|
else {
|
||||||
files.push({
|
files.push({
|
||||||
filename: `gemini.${Date.now().toString(36)}.txt`,
|
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||||
value: Buffer.from(output)
|
value: Buffer.from(res.body.candidates[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return editOrReply(context, {
|
if(!res.body.candidates || res.body.candidates?.length <= 1) return editOrReply(context, {
|
||||||
embeds:[createEmbed("defaultNoFooter", context, {
|
embeds:[createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
name: stringwrap(input, 50, false),
|
name: stringwrap(args.text, 50, false),
|
||||||
iconUrl: STATIC_ICONS.ai_gemini
|
iconUrl: STATIC_ICONS.ai_bard_idle
|
||||||
},
|
},
|
||||||
description: description.join('\n'),
|
description: description.join('\n'),
|
||||||
footer: {
|
footer: {
|
||||||
text: `Generative AI is experimental • Data submitted to Gemini may be used by Google for training.`
|
text: `Gemini • Gemini may display inaccurate info, so double-check its responses.`
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
files
|
files
|
||||||
})
|
})
|
||||||
|
// Draft support
|
||||||
|
else {
|
||||||
|
|
||||||
|
let currentView;
|
||||||
|
|
||||||
|
const components = new Components({
|
||||||
|
timeout: 100000,
|
||||||
|
run: async (ctx) => {
|
||||||
|
if (ctx.userId !== context.userId) return await ctx.respond(InteractionCallbackTypes.DEFERRED_UPDATE_MESSAGE);
|
||||||
|
|
||||||
|
// this sucks but works, ensures the newly selected option stays selected
|
||||||
|
for (let i = 0; i < components.components[0].components[0].options.length; i++) {
|
||||||
|
components.components[0].components[0].options[i].default = (components.components[0].components[0].options[i].value == ctx.data.values[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
draft = res.body.candidates[parseInt(ctx.data.values[0].replace('draft-', ''))]
|
||||||
|
|
||||||
|
description = []
|
||||||
|
files = [];
|
||||||
|
|
||||||
|
if(draft.length <= 4000) description.push(draft)
|
||||||
|
else {
|
||||||
|
files.push({
|
||||||
|
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||||
|
value: Buffer.from(draft)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
currentView = createEmbed("defaultNoFooter", context, {
|
||||||
|
author: {
|
||||||
|
name: stringwrap(args.text, 50, false),
|
||||||
|
iconUrl: STATIC_ICONS.ai_bard_idle
|
||||||
|
},
|
||||||
|
description: description.join('\n'),
|
||||||
|
footer: {
|
||||||
|
text: `Bard • Generative AI is experimental. Response may be factually wrong or completely made up.`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await ctx.editOrRespond({
|
||||||
|
embeds:[currentView],
|
||||||
|
files,
|
||||||
|
components
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let draftOptions = [];
|
||||||
|
for (let i = 0; i < res.body.candidates.length; i++) {
|
||||||
|
draftOptions.push({
|
||||||
|
label: `Draft ${i + 1}: ${stringwrap(res.body.candidates[i], 50, false)}`,
|
||||||
|
value: "draft-" + (i),
|
||||||
|
default: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
components.addSelectMenu({
|
||||||
|
placeholder: "View other drafts",
|
||||||
|
customId: "bard-drafts",
|
||||||
|
options: draftOptions
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(()=>{
|
||||||
|
editOrReply(context, {
|
||||||
|
embeds:[currentView],
|
||||||
|
components:[]
|
||||||
|
})
|
||||||
|
}, 100000)
|
||||||
|
|
||||||
|
currentView = createEmbed("defaultNoFooter", context, {
|
||||||
|
author: {
|
||||||
|
name: stringwrap(args.text, 50, false),
|
||||||
|
iconUrl: STATIC_ICONS.ai_bard_idle
|
||||||
|
},
|
||||||
|
description: description.join('\n'),
|
||||||
|
footer: {
|
||||||
|
text: `Bard • Generative AI is experimental. Response may be factually wrong or completely made up.`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds:[currentView],
|
||||||
|
files,
|
||||||
|
components
|
||||||
|
})
|
||||||
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
|
if(e.response?.body?.message) return editOrReply(context, createEmbed("warning", context, e.response.body.message))
|
||||||
|
|
||||||
console.log(e)
|
console.log(e)
|
||||||
if(e.response?.body?.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
|
||||||
return editOrReply(context, createEmbed("error", context, `Unable to generate response.`))
|
return editOrReply(context, createEmbed("error", context, `Unable to generate response.`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,12 +141,12 @@ const Statics = Object.freeze({
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
ai_bard: {
|
ai_bard: {
|
||||||
file: "icons/core/ico_bard_loading.gif",
|
file: "_gemini/gspark_processing.zk25zt28.gif",
|
||||||
revision: 0
|
revision: 1
|
||||||
},
|
},
|
||||||
ai_bard_idle: {
|
ai_bard_idle: {
|
||||||
file: "icons/core/ico_bard_idle.gif",
|
file: "_gemini/gspark_idle.10dm7yti7.gif",
|
||||||
revision: 0
|
revision: 1
|
||||||
},
|
},
|
||||||
ai_clyde: {
|
ai_clyde: {
|
||||||
file: "brands/_clyde/clyde_generating.gif",
|
file: "brands/_clyde/clyde_generating.gif",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue