mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-14 09:03:04 -04:00
migrate ai commands to obelisk
This commit is contained in:
parent
3b478bd69e
commit
641ab48053
6 changed files with 52 additions and 50 deletions
|
@ -8,6 +8,7 @@ const superagent = require('superagent')
|
||||||
const { iconPill, stringwrap, smallIconPill } = require('../../../labscore/utils/markdown')
|
const { iconPill, stringwrap, smallIconPill } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
const { chatgpt } = require('../../../labscore/api/obelisk');
|
||||||
|
|
||||||
const MODELS = {
|
const MODELS = {
|
||||||
"chatgpt": {
|
"chatgpt": {
|
||||||
|
@ -78,27 +79,23 @@ module.exports = {
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai", context, "Generating response..."))
|
await editOrReply(context, createEmbed("ai", context, "Generating response..."))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/openai`)
|
let res;
|
||||||
.set({
|
if(model.toLowerCase() == "chatgpt"){
|
||||||
Authorization: process.env.AI_SERVER_KEY
|
res = await chatgpt(context, prompt, input)
|
||||||
})
|
} else if (model.toLowerCase() == "gpt4"){
|
||||||
.send({
|
res = await chatgpt(context, prompt, input)
|
||||||
prompt,
|
}
|
||||||
input: [input],
|
|
||||||
temperature,
|
|
||||||
model: MODELS[model.toLowerCase()].id
|
|
||||||
})
|
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
if(!res.body.output) throw "Unable to generate response"
|
if(!res.response.body.output) throw "Unable to generate response"
|
||||||
|
|
||||||
if(res.body.output.length <= 4000) description.push(res.body.output)
|
if(res.response.body.output.length <= 4000) description.push(res.response.body.output)
|
||||||
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.response.body.output)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ const { iconPill, stringwrap } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
const { getUser } = require('../../../labscore/utils/users');
|
const { getUser } = require('../../../labscore/utils/users');
|
||||||
|
const { chatgpt } = require('../../../labscore/api/obelisk');
|
||||||
|
|
||||||
const LOADING_QUIPS = [
|
const LOADING_QUIPS = [
|
||||||
"Crunching the data, one byte at a time...",
|
"Crunching the data, one byte at a time...",
|
||||||
|
@ -86,16 +87,8 @@ Current time: ${new Date().toLocaleDateString('en-us', { weekday:"long", year:"n
|
||||||
|
|
||||||
await editOrReply(context, e)
|
await editOrReply(context, e)
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/openai`)
|
let res = await chatgpt(context, prompt, input);
|
||||||
.set({
|
res = res.response;
|
||||||
Authorization: process.env.AI_SERVER_KEY
|
|
||||||
})
|
|
||||||
.send({
|
|
||||||
prompt,
|
|
||||||
input: [input],
|
|
||||||
temperature: "0.75",
|
|
||||||
model: "CHATGPT"
|
|
||||||
})
|
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
|
@ -6,7 +6,8 @@ const { codeblock, iconPill, smallIconPill } = require('../../../labscore/utils/
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
||||||
const { STATICS } = require('../../../labscore/utils/statics')
|
const { STATICS } = require('../../../labscore/utils/statics');
|
||||||
|
const { chatgpt } = require('../../../labscore/api/obelisk');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'disstrack',
|
name: 'disstrack',
|
||||||
|
@ -24,18 +25,11 @@ module.exports = {
|
||||||
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).`))
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai", context, "Generating response..."))
|
await editOrReply(context, createEmbed("ai", context, "Spitting bars..."))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/openai`)
|
let res = await chatgpt(context, "Write a disstrack about the subject the user supplies. The disstrack should have at least one verse and a chorus.", args.text);
|
||||||
.set({
|
res = res.response;
|
||||||
Authorization: process.env.AI_SERVER_KEY
|
|
||||||
})
|
|
||||||
.send({
|
|
||||||
prompt: "Write a disstrack about the subject the user supplies. The disstrack should have at least two verses and a chorus.",
|
|
||||||
input: [args.text],
|
|
||||||
temperature: 0.6,
|
|
||||||
model: "CHATGPT"
|
|
||||||
})
|
|
||||||
return editOrReply(context, createEmbed("default", context, {
|
return editOrReply(context, createEmbed("default", context, {
|
||||||
description: smallIconPill("generative_ai", args.text) + '\n' + codeblock("ansi", [res.body.output.substr(0, 2020 - args.text.length)]),
|
description: smallIconPill("generative_ai", args.text) + '\n' + codeblock("ansi", [res.body.output.substr(0, 2020 - args.text.length)]),
|
||||||
footer: {
|
footer: {
|
||||||
|
|
|
@ -8,6 +8,7 @@ const superagent = require('superagent')
|
||||||
const { iconPill, stringwrap, smallIconPill } = require('../../../labscore/utils/markdown')
|
const { iconPill, stringwrap, smallIconPill } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
const { palm2 } = require('../../../labscore/api/obelisk');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'palm',
|
name: 'palm',
|
||||||
|
@ -56,17 +57,9 @@ module.exports = {
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_palm_idle))
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_palm_idle))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2/chat`)
|
let res = await palm2(context, prompt, input)
|
||||||
.set({
|
res = res.response;
|
||||||
Authorization: process.env.AI_SERVER_KEY
|
|
||||||
})
|
|
||||||
.send({
|
|
||||||
prompt,
|
|
||||||
input: [input],
|
|
||||||
temperature,
|
|
||||||
model
|
|
||||||
})
|
|
||||||
|
|
||||||
let description = []
|
let description = []
|
||||||
let files = [];
|
let files = [];
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,12 @@ const ObeliskApi = Object.freeze({
|
||||||
HOST: ObeliskHosts.prod,
|
HOST: ObeliskHosts.prod,
|
||||||
|
|
||||||
GOOGLE_BARD: "/parrot/v1/google:bard",
|
GOOGLE_BARD: "/parrot/v1/google:bard",
|
||||||
GEMINI_PRO: "/parrot/v1/google:gemini",
|
GOOGLE_GEMINI_PRO: "/parrot/v1/google:gemini",
|
||||||
GEMINI_PRO_VISION: "/parrot/v1/google:geminiVision",
|
GOOGLE_GEMINI_PRO_VISION: "/parrot/v1/google:geminiVision",
|
||||||
|
GOOGLE_PALM2: "/parrot/v1/google:palm2",
|
||||||
|
|
||||||
|
OPENAI_CHATGPT: "/parrot/v1/openai:chatgpt",
|
||||||
|
OPENAI_GPT4: "/parrot/v1/openai:gpt4",
|
||||||
|
|
||||||
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize"
|
SUMMARIZE_WEBPAGES: "/flamingo/v1/web:summarize"
|
||||||
})
|
})
|
||||||
|
|
|
@ -48,18 +48,39 @@ module.exports.bard = async function(context, input){
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.gemini = async function(context, prompt){
|
module.exports.gemini = async function(context, prompt){
|
||||||
return await request(ObeliskApi.GEMINI_PRO, "POST", {}, {
|
return await request(ObeliskApi.GOOGLE_GEMINI_PRO, "POST", {}, {
|
||||||
prompt
|
prompt
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.geminiVision = async function(context, input, url){
|
module.exports.geminiVision = async function(context, input, url){
|
||||||
return await request(ObeliskApi.GEMINI_PRO_VISION, "POST", {}, {
|
return await request(ObeliskApi.GOOGLE_GEMINI_PRO_VISION, "POST", {}, {
|
||||||
input,
|
input,
|
||||||
url
|
url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.palm2 = async function(context, prompt, input){
|
||||||
|
return await request(ObeliskApi.GOOGLE_PALM2, "POST", {}, {
|
||||||
|
prompt,
|
||||||
|
input
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.chatgpt = async function(context, prompt, input){
|
||||||
|
return await request(ObeliskApi.OPENAI_CHATGPT, "POST", {}, {
|
||||||
|
prompt,
|
||||||
|
input
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.gpt4 = async function(context, prompt, input){
|
||||||
|
return await request(ObeliskApi.OPENAI_GPT4, "POST", {}, {
|
||||||
|
prompt,
|
||||||
|
input
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// FLAMINGO
|
// 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", {}, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue