add stablelm

This commit is contained in:
derpystuff 2023-04-21 21:14:38 +02:00
parent f11cb26560
commit 4733de1c5d
4 changed files with 58 additions and 3 deletions

View file

@ -22,7 +22,7 @@ module.exports = {
}
],
run: async (context, args) => {
const MODEL = "replicate:alpaca-7b"
const MODEL = "replicate:replicate/alpaca-7b"
try{
let s = Date.now()
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})

View file

@ -0,0 +1,52 @@
const { Constants } = require('detritus-client');
const { InteractionCallbackTypes, ApplicationCommandOptionTypes } = Constants;
const { AI_GPT_MODEL_CONFIG } = require("../../../../labscore/constants");
const superagent = require('superagent')
const { createEmbed } = require('../../../../labscore/utils/embed');
const { codeblock } = require('../../../../labscore/utils/markdown');
const { format } = require('../../../../labscore/utils/ansi');
module.exports = {
description: 'StableLM (Stability AI stablelm-tuned-alpha-7b)',
name: 'stablelm',
type: ApplicationCommandOptionTypes.SUB_COMMAND,
options: [
{
name: 'prompt',
description: 'Prompt',
type: ApplicationCommandOptionTypes.STRING,
required: true,
maxLength: 256
}
],
run: async (context, args) => {
const MODEL = "replicate:stability-ai/stablelm-tuned-alpha-7b"
try{
let s = Date.now()
await context.respond({data: {}, type: InteractionCallbackTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE})
let res = await superagent.get(`${process.env.AI_SERVER}/gpt`)
.query({
model: MODEL,
prompt: args.prompt
})
await context.editOrRespond({
embeds: [createEmbed("default", context, {
footer: {
iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ai/ico_ai_${AI_GPT_MODEL_CONFIG[MODEL].icon}.png`,
text: `${AI_GPT_MODEL_CONFIG[MODEL].name}${context.application.name}`,
},
description: codeblock("ansi", [res.body.response.substr(0, 1024).replace(/\\n/g,'\n')])
})]
})
}catch(e){
console.log(e)
await context.editOrRespond({
embeds: [createEmbed("error", context, "Unable to generate response. Try again in a bit.")]
})
}
},
};