mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-17 02:17:05 -04:00
aiwp
This commit is contained in:
parent
1291974b5a
commit
b5da631448
5 changed files with 79 additions and 2 deletions
|
@ -21,7 +21,6 @@ function validateNumber(input, low, high){
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'art',
|
name: 'art',
|
||||||
aliases: ['wallpaper'],
|
|
||||||
metadata: {
|
metadata: {
|
||||||
description: 'Creates colorful generative art using JetBrains LIMB.',
|
description: 'Creates colorful generative art using JetBrains LIMB.',
|
||||||
description_short: 'AI wallpaper generation',
|
description_short: 'AI wallpaper generation',
|
||||||
|
|
63
commands/message/genai/aiwallpaper.js
Normal file
63
commands/message/genai/aiwallpaper.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
const { geminiVision, aiWallpaper } = require("../../../labscore/api/obelisk");
|
||||||
|
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
||||||
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
|
const { getUser } = require("../../../labscore/utils/users");
|
||||||
|
|
||||||
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
|
||||||
|
const { STATIC_ICONS } = require("../../../labscore/utils/statics");
|
||||||
|
const { iconPill, stringwrap } = require("../../../labscore/utils/markdown");
|
||||||
|
const { hasFeature } = require("../../../labscore/utils/testing");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'aiwallpaper',
|
||||||
|
label: 'text',
|
||||||
|
aliases: ['wallpaper'],
|
||||||
|
metadata: {
|
||||||
|
description: `${iconPill("generative_ai", "LIMITED TESTING")}\n\nCreate Wallpapers`,
|
||||||
|
description_short: 'Create Wallpapers',
|
||||||
|
examples: ['aiwp northern lights -style art'],
|
||||||
|
category: 'limited',
|
||||||
|
usage: 'aiwallpaper <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/wallpapers")) return;
|
||||||
|
context.triggerTyping();
|
||||||
|
|
||||||
|
if(!args.text) return editOrReply(context, createEmbed("warning", context, `Missing Parameter (prompt).`))
|
||||||
|
|
||||||
|
let input = args.text;
|
||||||
|
|
||||||
|
try{
|
||||||
|
await editOrReply(context, createEmbed("ai", context, "Generating Image..."))
|
||||||
|
|
||||||
|
let res = await aiWallpaper(context, args.text, "translucent");
|
||||||
|
let imgName = `lcwp.${Date.now().toString(36)}.jpeg`;
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds:[createEmbed("defaultNoFooter", context, {
|
||||||
|
author: {
|
||||||
|
iconUrl: STATIC_ICONS.ai_image,
|
||||||
|
name: stringwrap(args.text, 50, false),
|
||||||
|
},
|
||||||
|
image: {
|
||||||
|
url: `attachment://${imgName}`
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
text: `Generative AI is experimental • Use AI Images responsibly.`
|
||||||
|
}
|
||||||
|
})],
|
||||||
|
files: [{
|
||||||
|
filename: imgName,
|
||||||
|
value: res.response.body
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
} 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 image.`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -14,7 +14,9 @@ const ObeliskApi = Object.freeze({
|
||||||
OPENAI_CHATGPT: "/parrot/v1/openai:chatgpt",
|
OPENAI_CHATGPT: "/parrot/v1/openai:chatgpt",
|
||||||
OPENAI_GPT4: "/parrot/v1/openai:gpt4",
|
OPENAI_GPT4: "/parrot/v1/openai:gpt4",
|
||||||
|
|
||||||
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize"
|
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize",
|
||||||
|
|
||||||
|
AI_WALLPAPER: "/robin/v1/wallpaper:generate"
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -87,3 +87,11 @@ module.exports.summarizeWebpage = async function(context, url){
|
||||||
url
|
url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ROBIN
|
||||||
|
module.exports.aiWallpaper = async function(context, prompt, style){
|
||||||
|
return await request(ObeliskApi.AI_WALLPAPER, "POST", {}, {
|
||||||
|
prompt,
|
||||||
|
style
|
||||||
|
})
|
||||||
|
}
|
|
@ -164,6 +164,10 @@ const Statics = Object.freeze({
|
||||||
file: "icons/flamingo/web_summary.png",
|
file: "icons/flamingo/web_summary.png",
|
||||||
revision: 1
|
revision: 1
|
||||||
},
|
},
|
||||||
|
ai_image: {
|
||||||
|
file: "icons/flamingo/image_generation.png",
|
||||||
|
revision: 2
|
||||||
|
},
|
||||||
warning: {
|
warning: {
|
||||||
file: "icons/core/ico_notice_warning.png",
|
file: "icons/core/ico_notice_warning.png",
|
||||||
revision: 3
|
revision: 3
|
||||||
|
@ -216,6 +220,7 @@ module.exports.STATIC_ICONS = Object.freeze({
|
||||||
ai_gemini: staticAsset(Statics.icons.ai_gemini),
|
ai_gemini: staticAsset(Statics.icons.ai_gemini),
|
||||||
ai_palm_idle: staticAsset(Statics.icons.ai_palm_idle),
|
ai_palm_idle: staticAsset(Statics.icons.ai_palm_idle),
|
||||||
ai_summary: staticAsset(Statics.icons.ai_summary),
|
ai_summary: staticAsset(Statics.icons.ai_summary),
|
||||||
|
ai_image: staticAsset(Statics.icons.ai_image),
|
||||||
warning: staticAsset(Statics.icons.warning)
|
warning: staticAsset(Statics.icons.warning)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue