mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import { AbstractTool } from './AbstractTool.js'
|
|
|
|
export class APTool extends AbstractTool {
|
|
name = 'draw'
|
|
|
|
parameters = {
|
|
properties: {
|
|
prompt: {
|
|
type: 'string',
|
|
description: 'draw prompt of StableDiffusion, must be in English'
|
|
}
|
|
},
|
|
required: ['prompt']
|
|
}
|
|
|
|
description = 'Useful when you want to draw picture'
|
|
|
|
func = async function (opts, e) {
|
|
let { prompt } = opts
|
|
e.message = e.message.filter(m => m.type !== 'at' || m.qq !== Bot.uin)
|
|
let ap
|
|
try {
|
|
// eslint-disable-next-line camelcase
|
|
let { Ai_Painting } = await import('../../../ap-plugin/apps/aiPainting.js')
|
|
ap = new Ai_Painting(e)
|
|
} catch (err) {
|
|
try {
|
|
// ap的dev分支改名了
|
|
// eslint-disable-next-line camelcase
|
|
let { Ai_Painting } = await import('../../../ap-plugin/apps/ai_painting.js')
|
|
ap = new Ai_Painting(e)
|
|
} catch (err1) {
|
|
return 'the user didn\'t install ap-plugin. suggest him to install'
|
|
}
|
|
}
|
|
try {
|
|
e.msg = '#绘图' + prompt
|
|
await ap.aiPainting(e)
|
|
return 'draw success!'
|
|
} catch (err) {
|
|
return 'draw failed due to unknown error'
|
|
}
|
|
}
|
|
}
|