mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-16 01:53:08 -04:00
ai changes
This commit is contained in:
parent
33cc03d910
commit
1aa6018089
3 changed files with 80 additions and 5 deletions
|
@ -22,7 +22,7 @@ module.exports = {
|
||||||
args: [
|
args: [
|
||||||
{ name: 'prompt', default: '', required: false, help: "The starting system prompt." },
|
{ name: 'prompt', default: '', required: false, help: "The starting system prompt." },
|
||||||
],
|
],
|
||||||
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
|
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(!canUseLimitedTestCommands(context)) return;
|
if(!canUseLimitedTestCommands(context)) return;
|
||||||
context.triggerTyping();
|
context.triggerTyping();
|
||||||
|
|
76
commands/message/fun/dalle.js
Normal file
76
commands/message/fun/dalle.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
|
|
||||||
|
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
||||||
|
const { STATICS } = require('../../../labscore/utils/statics');
|
||||||
|
|
||||||
|
const superagent = require('superagent')
|
||||||
|
const { iconPill, smallIconPill } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'dalle',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nGenerate images with DALL-E 2`,
|
||||||
|
description_short: 'Generate images with DALL-E 2.',
|
||||||
|
examples: ['dalle Otter, in the style of the great wave'],
|
||||||
|
category: 'limited',
|
||||||
|
usage: 'dalle <prompt>'
|
||||||
|
},
|
||||||
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
|
||||||
|
run: async (context, args) => {
|
||||||
|
if(!canUseLimitedTestCommands(context)) return;
|
||||||
|
context.triggerTyping();
|
||||||
|
if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]})
|
||||||
|
|
||||||
|
let prompt = 'You are a friendly chat bot designed to help people. You should always use gender neutral pronouns when possible.'
|
||||||
|
if(args.prompt !== "") prompt = args.prompt
|
||||||
|
|
||||||
|
try{
|
||||||
|
await editOrReply(context, createEmbed("ai", context, "Generating image..."))
|
||||||
|
|
||||||
|
let res = await superagent.post(`${process.env.AI_SERVER}/openai/dalle`)
|
||||||
|
.set({
|
||||||
|
Authorization: process.env.AI_SERVER_KEY
|
||||||
|
})
|
||||||
|
.send({
|
||||||
|
prompt: args.text,
|
||||||
|
model: "DALLE2"
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Fetch the image
|
||||||
|
let img = await superagent.get(res.body.output)
|
||||||
|
|
||||||
|
let description = [smallIconPill("generative_ai", args.text), '']
|
||||||
|
let files = [];
|
||||||
|
|
||||||
|
if(!res.body.output) res.body.output = '[Empty Response]'
|
||||||
|
|
||||||
|
const f = `lcdalle.${Date.now().toString(36)}.png`;
|
||||||
|
files.push({
|
||||||
|
filename: f,
|
||||||
|
value: img.body
|
||||||
|
})
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds:[createEmbed("default", context, {
|
||||||
|
description: description.join('\n'),
|
||||||
|
image: {
|
||||||
|
url: "attachment://" + f
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
text: `OpenAI DALL-E 2 • ${context.application.name}`,
|
||||||
|
iconUrl: STATICS.openai
|
||||||
|
}
|
||||||
|
})],
|
||||||
|
files
|
||||||
|
})
|
||||||
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate text.`)]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -7,15 +7,14 @@ const { Permissions } = require("detritus-client/lib/constants");
|
||||||
const { STATICS } = require("../../../labscore/utils/statics");
|
const { STATICS } = require("../../../labscore/utils/statics");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'dalle',
|
name: 'craiyon',
|
||||||
label: 'query',
|
label: 'query',
|
||||||
aliases: ['craiyon'],
|
|
||||||
metadata: {
|
metadata: {
|
||||||
description: 'Uses Craiyon to generate four images from a text prompt.',
|
description: 'Uses Craiyon to generate four images from a text prompt.',
|
||||||
description_short: 'Craiyon AI image generation',
|
description_short: 'Craiyon AI image generation',
|
||||||
examples: ['dalle Otter'],
|
examples: ['craiyon Otter'],
|
||||||
category: 'image',
|
category: 'image',
|
||||||
usage: 'dalle <text>'
|
usage: 'craiyon <text>'
|
||||||
},
|
},
|
||||||
ratelimit: {
|
ratelimit: {
|
||||||
type: 'guild',
|
type: 'guild',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue