mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +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
13
apps/chat.js
13
apps/chat.js
|
|
@ -1,6 +1,6 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import _ from 'lodash'
|
||||
import { Config, defaultOpenAIAPI, pureSydneyInstruction } from '../utils/config.js'
|
||||
import { Config, defaultOpenAIAPI } from '../utils/config.js'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import delay from 'delay'
|
||||
import { ChatGPTAPI } from '../utils/openai/chatgpt-api.js'
|
||||
|
|
@ -61,8 +61,9 @@ import { SerpIkechan8370Tool } from '../utils/tools/SerpIkechan8370Tool.js'
|
|||
import { SendPictureTool } from '../utils/tools/SendPictureTool.js'
|
||||
import { SerpImageTool } from '../utils/tools/SearchImageTool.js'
|
||||
import { ImageCaptionTool } from '../utils/tools/ImageCaptionTool.js'
|
||||
import {TTSTool} from "../utils/tools/TTSTool.js";
|
||||
import {ProcessPictureTool} from "../utils/tools/ProcessPictureTool.js";
|
||||
import { TTSTool } from '../utils/tools/TTSTool.js'
|
||||
import { ProcessPictureTool } from '../utils/tools/ProcessPictureTool.js'
|
||||
import { APTool } from '../utils/tools/APTool.js'
|
||||
try {
|
||||
await import('emoji-strip')
|
||||
} catch (err) {
|
||||
|
|
@ -1975,7 +1976,8 @@ export class chatgpt extends plugin {
|
|||
new SerpIkechan8370Tool(),
|
||||
new SerpTool(),
|
||||
new TTSTool(),
|
||||
new ProcessPictureTool()
|
||||
new ProcessPictureTool(),
|
||||
new APTool()
|
||||
]
|
||||
// todo 3.0再重构tool的插拔和管理
|
||||
let tools = [
|
||||
|
|
@ -1989,6 +1991,7 @@ export class chatgpt extends plugin {
|
|||
new WeatherTool(),
|
||||
new SendPictureTool(),
|
||||
new TTSTool(),
|
||||
new APTool(),
|
||||
serpTool
|
||||
]
|
||||
let img = []
|
||||
|
|
@ -2059,7 +2062,7 @@ export class chatgpt extends plugin {
|
|||
} catch (err) {
|
||||
args.groupId = e.group_id + '' || e.sender.user_id + ''
|
||||
}
|
||||
let functionResult = await fullFuncMap[name].exec(Object.assign({ isAdmin, sender }, args))
|
||||
let functionResult = await fullFuncMap[name].exec(Object.assign({ isAdmin, sender }, args), e)
|
||||
logger.mark(`function ${name} execution result: ${functionResult}`)
|
||||
option.parentMessageId = msg.id
|
||||
option.name = name
|
||||
|
|
|
|||
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