mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 22:23:03 -04:00
upload big responses as files
This commit is contained in:
parent
4e2739a254
commit
ddb2a0cfa1
1 changed files with 22 additions and 10 deletions
|
@ -1,12 +1,13 @@
|
||||||
const { createEmbed } = require('../../../labscore/utils/embed')
|
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
const { editOrReply } = require('../../../labscore/utils/message')
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
|
|
||||||
|
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
||||||
|
const { STATICS } = require('../../../labscore/utils/statics');
|
||||||
|
|
||||||
const superagent = require('superagent')
|
const superagent = require('superagent')
|
||||||
const { iconPill, smallIconPill } = require('../../../labscore/utils/markdown')
|
const { iconPill, smallIconPill } = require('../../../labscore/utils/markdown')
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
const { canUseLimitedTestCommands } = require('../../../labscore/utils/testing')
|
|
||||||
const { STATICS } = require('../../../labscore/utils/statics')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'chat',
|
name: 'chat',
|
||||||
|
@ -45,15 +46,26 @@ module.exports = {
|
||||||
})
|
})
|
||||||
|
|
||||||
let description = [smallIconPill("generative_ai", args.text), '']
|
let description = [smallIconPill("generative_ai", args.text), '']
|
||||||
description.push(res.body.output.substr(0, 2000 - args.text.length))
|
let files = [];
|
||||||
|
|
||||||
return editOrReply(context, {embeds:[createEmbed("default", context, {
|
if(res.body.output.length <= 2000) description.push(res.body.output.substr(0, 2000 - args.text.length))
|
||||||
|
else {
|
||||||
|
files.push({
|
||||||
|
filename: `chat.${Date.now().toString(36)}.txt`,
|
||||||
|
value: Buffer.from(res.body.output)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return editOrReply(context, {
|
||||||
|
embeds:[createEmbed("default", context, {
|
||||||
description: description.join('\n').substr(),
|
description: description.join('\n').substr(),
|
||||||
footer: {
|
footer: {
|
||||||
text: `This information may be inaccurate or biased • ${context.application.name}`,
|
text: `This information may be inaccurate or biased • ${context.application.name}`,
|
||||||
iconUrl: STATICS.openai
|
iconUrl: STATICS.openai
|
||||||
}
|
}
|
||||||
})]})
|
})],
|
||||||
|
files
|
||||||
|
})
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate text.`)]})
|
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate text.`)]})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue