mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
fix bard
This commit is contained in:
parent
52d7e6c25d
commit
4aa15da120
3 changed files with 16 additions and 13 deletions
|
@ -9,6 +9,7 @@ const { iconPill, stringwrap } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
const { Permissions, InteractionCallbackTypes } = require("detritus-client/lib/constants");
|
||||||
const { Components } = require('detritus-client/lib/utils');
|
const { Components } = require('detritus-client/lib/utils');
|
||||||
|
const { bard } = require('../../../labscore/api/obelisk');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'bard',
|
name: 'bard',
|
||||||
|
@ -33,27 +34,19 @@ module.exports = {
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/google/bard`)
|
let res = await bard(context, input)
|
||||||
.set({
|
res = res.response
|
||||||
Authorization: process.env.AI_SERVER_KEY
|
|
||||||
})
|
|
||||||
.query({
|
|
||||||
with_drafts: true
|
|
||||||
})
|
|
||||||
.send({
|
|
||||||
input
|
|
||||||
})
|
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
if(!res.body.output) return editOrReply(context, createEmbed("error", context, `Bard returned an error. Try again later.`))
|
if(!res.body.drafts) return editOrReply(context, createEmbed("error", context, `Bard returned an error. Try again later.`))
|
||||||
|
|
||||||
if(res.body.output.length <= 4000) description.push(res.body.output)
|
if(res.body.drafts[0].length <= 4000) description.push(res.body.drafts[0])
|
||||||
else {
|
else {
|
||||||
files.push({
|
files.push({
|
||||||
filename: `chat.${Date.now().toString(36)}.txt`,
|
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||||
value: Buffer.from(res.body.output)
|
value: Buffer.from(res.body.drafts[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ const ObeliskHosts = Object.freeze({
|
||||||
const ObeliskApi = Object.freeze({
|
const ObeliskApi = Object.freeze({
|
||||||
HOST: ObeliskHosts.prod,
|
HOST: ObeliskHosts.prod,
|
||||||
|
|
||||||
|
GOOGLE_BARD: "/parrot/v1/google:bard",
|
||||||
|
|
||||||
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize"
|
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,14 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GENERATIVEAI
|
||||||
|
module.exports.bard = async function(context, input){
|
||||||
|
return await request(ObeliskApi.GOOGLE_BARD, "POST", {}, {
|
||||||
|
input
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// FLAMINGO
|
||||||
module.exports.summarizeWebpage = async function(context, url){
|
module.exports.summarizeWebpage = async function(context, url){
|
||||||
return await request(ObeliskApi.SUMMARIZE_WEBPAGES, "POST", {}, {
|
return await request(ObeliskApi.SUMMARIZE_WEBPAGES, "POST", {}, {
|
||||||
url
|
url
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue