feat: try to support ap-plugin

This commit is contained in:
ikechan8370 2023-06-25 18:07:23 +08:00
parent 03b02442fa
commit a35f8a31a0
2 changed files with 44 additions and 5 deletions

36
utils/tools/APTool.js Normal file
View file

@ -0,0 +1,36 @@
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'
func = async function (opts, e) {
let { prompt } = opts
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) {
return 'the user didn\'t install ap-plugin'
}
try {
e.msg = '#绘图' + prompt
await ap.aiPainting(e)
return 'draw success!'
} catch (err) {
return 'draw failed due to unknown error'
}
}
}