mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 22:23:03 -04:00
use imagen3
This commit is contained in:
parent
91c7a6850c
commit
90b4b0c6a8
3 changed files with 13 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
const {googleGenaiImagen} = require("#api");
|
||||||
const { PERMISSION_GROUPS } = require("#constants");
|
const { PERMISSION_GROUPS } = require("#constants");
|
||||||
const { GenerativeImagesModelsImagen } = require("#obelisk");
|
|
||||||
|
|
||||||
const { createEmbed } = require("#utils/embed");
|
const { createEmbed } = require("#utils/embed");
|
||||||
const { acknowledge } = require("#utils/interactions");
|
const { acknowledge } = require("#utils/interactions");
|
||||||
|
@ -39,20 +39,20 @@ module.exports = {
|
||||||
url: STATIC_ASSETS.image_loading_splash(Math.floor(Math.random()*10))
|
url: STATIC_ASSETS.image_loading_splash(Math.floor(Math.random()*10))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
};
|
}
|
||||||
|
|
||||||
await editOrReply(context, {embeds: loadingEmbeds});
|
await editOrReply(context, {embeds: loadingEmbeds});
|
||||||
|
|
||||||
let res = await GenerativeImagesModelsImagen(context, args.text);
|
let res = await googleGenaiImagen(context, args.text);
|
||||||
|
|
||||||
// Construct Embeds
|
// Construct Embeds
|
||||||
let files = [];
|
let files = [];
|
||||||
let embeds = res.response.body.images.map((i)=>{
|
let embeds = res.response.body.predictions.map((i)=>{
|
||||||
let imgName = `lcigen.${(Date.now() + Math.random()).toString(36)}.jpeg`;
|
let imgName = `lcigen.${(Date.now() + Math.random()).toString(36)}.${i.mimeType.split("/")[1]}`;
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
filename: imgName,
|
filename: imgName,
|
||||||
value: Buffer.from(i, 'base64')
|
value: Buffer.from(i.bytesBase64Encoded, 'base64')
|
||||||
})
|
})
|
||||||
return createEmbed("defaultNoFooter", context, {
|
return createEmbed("defaultNoFooter", context, {
|
||||||
url: "https://bignutty.gitlab.io",
|
url: "https://bignutty.gitlab.io",
|
||||||
|
|
|
@ -7,6 +7,7 @@ const Hosts = Object.freeze({
|
||||||
const Api = Object.freeze({
|
const Api = Object.freeze({
|
||||||
HOST: Hosts.prod,
|
HOST: Hosts.prod,
|
||||||
|
|
||||||
|
GOOGLE_GENERATIVEAI_IMAGEN: '/google/generativeai/imagen',
|
||||||
GOOGLE_PERSPECTIVE: '/google/perspective/analyze',
|
GOOGLE_PERSPECTIVE: '/google/perspective/analyze',
|
||||||
GOOGLE_SPEECH_RECOGNIZE: '/google/speech/recognize',
|
GOOGLE_SPEECH_RECOGNIZE: '/google/speech/recognize',
|
||||||
GOOGLE_SPEECH_RECOGNIZE_LABELS: '/google/speech/multirecognize',
|
GOOGLE_SPEECH_RECOGNIZE_LABELS: '/google/speech/multirecognize',
|
||||||
|
|
|
@ -42,6 +42,12 @@ async function request(path, type, headers, args, host) {
|
||||||
throw new Error("unsupported, must either use GET or POST");
|
throw new Error("unsupported, must either use GET or POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.googleGenaiImagen = async function(context, prompt){
|
||||||
|
return await request(Api.GOOGLE_GENERATIVEAI_IMAGEN, "GET", {}, {
|
||||||
|
prompt: prompt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.googlePerspective = async function(context, text){
|
module.exports.googlePerspective = async function(context, text){
|
||||||
return await request(Api.GOOGLE_PERSPECTIVE, "GET", {}, {
|
return await request(Api.GOOGLE_PERSPECTIVE, "GET", {}, {
|
||||||
text: text
|
text: text
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue