mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: try to support ap-plugin
This commit is contained in:
parent
03b02442fa
commit
a35f8a31a0
2 changed files with 44 additions and 5 deletions
36
utils/tools/APTool.js
Normal file
36
utils/tools/APTool.js
Normal 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'
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue