mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
Merge branch 'v2' into v2
This commit is contained in:
commit
e1380e3ad8
6 changed files with 28 additions and 7 deletions
25
apps/bym.js
25
apps/bym.js
|
|
@ -19,6 +19,7 @@ import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
||||||
import { SerpTool } from '../utils/tools/SerpTool.js'
|
import { SerpTool } from '../utils/tools/SerpTool.js'
|
||||||
import { initializeImageTool } from '../utils/tools/ImageTool.js'
|
import { initializeImageTool } from '../utils/tools/ImageTool.js'
|
||||||
import { DailyNewsTool } from '../utils/tools/DailyNewsTool.js'
|
import { DailyNewsTool } from '../utils/tools/DailyNewsTool.js'
|
||||||
|
import { SendMessageToSpecificGroupOrUserTool } from '../utils/tools/SendMessageToSpecificGroupOrUserTool.js'
|
||||||
|
|
||||||
const DefaultConfig = {
|
const DefaultConfig = {
|
||||||
returnQQ: [],
|
returnQQ: [],
|
||||||
|
|
@ -36,6 +37,7 @@ const DefaultConfig = {
|
||||||
// 轻微黑名单用户
|
// 轻微黑名单用户
|
||||||
let RoleFalseUser = []
|
let RoleFalseUser = []
|
||||||
|
|
||||||
|
|
||||||
export class bym extends plugin {
|
export class bym extends plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
|
@ -267,7 +269,7 @@ export class bym extends plugin {
|
||||||
Role = `现在看到的是${opt.images.length}张图片(从第1张到第${opt.images.length}张),请依次查看各张图片。若觉得是表情包,并不是通知或其他类型的图片,请发送 DOWNIMG: 命名该表情。不需要发送过多的参数,只需要发送格式DOWNIMG: 命名该表情,注意不需要携带后缀;若不是表情包等,请发送NOTIMG并对图片内容进行分析描述。注意:请从第1张图片开始依次描述。`;
|
Role = `现在看到的是${opt.images.length}张图片(从第1张到第${opt.images.length}张),请依次查看各张图片。若觉得是表情包,并不是通知或其他类型的图片,请发送 DOWNIMG: 命名该表情。不需要发送过多的参数,只需要发送格式DOWNIMG: 命名该表情,注意不需要携带后缀;若不是表情包等,请发送NOTIMG并对图片内容进行分析描述。注意:请从第1张图片开始依次描述。`;
|
||||||
break;
|
break;
|
||||||
case "default":
|
case "default":
|
||||||
Role = `你的名字是"${Config.assistantLabel}",你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。` +
|
Role = `你的名字是“${Config.assistantLabel}”,你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。如果此时不需要自己说话,可以只回复<EMPTY>` +
|
||||||
candidate +
|
candidate +
|
||||||
`以下是聊天记录:
|
`以下是聊天记录:
|
||||||
${Group_Chat}
|
${Group_Chat}
|
||||||
|
|
@ -306,6 +308,7 @@ export class bym extends plugin {
|
||||||
new WebsiteTool(),
|
new WebsiteTool(),
|
||||||
new WeatherTool(),
|
new WeatherTool(),
|
||||||
new DailyNewsTool()
|
new DailyNewsTool()
|
||||||
|
new SendMessageToSpecificGroupOrUserTool()
|
||||||
]
|
]
|
||||||
if (Config.azSerpKey) {
|
if (Config.azSerpKey) {
|
||||||
tools.push(new SerpTool())
|
tools.push(new SerpTool())
|
||||||
|
|
@ -329,7 +332,7 @@ export class bym extends plugin {
|
||||||
client.addTools(tools)
|
client.addTools(tools)
|
||||||
let rsp = await client.sendMessage(e.msg, opt)
|
let rsp = await client.sendMessage(e.msg, opt)
|
||||||
let text = rsp.text
|
let text = rsp.text
|
||||||
let texts = text.split(/(?<!\?)[。?\n](?!\?)/)
|
let texts = text.split(/(?<!\?)[。?\n](?!\?)/, 3)
|
||||||
for (let t of texts) {
|
for (let t of texts) {
|
||||||
if (!t || !t.trim()) {
|
if (!t || !t.trim()) {
|
||||||
continue
|
continue
|
||||||
|
|
@ -358,6 +361,7 @@ export class bym extends plugin {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let finalMsg = await convertFaces(t, true, e)
|
let finalMsg = await convertFaces(t, true, e)
|
||||||
|
finalMsg = finalMsg.map(filterResponseChunk).filter(i => !!i)
|
||||||
if (!finalMsg || (typeof finalMsg === 'string' && !finalMsg.trim())) {
|
if (!finalMsg || (typeof finalMsg === 'string' && !finalMsg.trim())) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -383,3 +387,20 @@ export class bym extends plugin {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤
|
||||||
|
* @param msg
|
||||||
|
*/
|
||||||
|
function filterResponseChunk (msg) {
|
||||||
|
if (!msg || typeof msg !== 'string') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (msg.trim() === '```') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (msg.trim() === '<EMPTY>') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,5 @@ export class SendAvatarTool extends AbstractTool {
|
||||||
return `the ${pictures.length > 1 ? 'users: ' + qq + '\'s avatar' : 'avatar'} has been sent to group ${target}`
|
return `the ${pictures.length > 1 ? 'users: ' + qq + '\'s avatar' : 'avatar'} has been sent to group ${target}`
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'Useful when you want to send the user avatar to the group. Note that if you want to process user\'s avatar, it is advisable to utilize the ProcessPictureTool and input the qq of target user.'
|
description = 'Useful when you want to send the user avatar to the group. Note that if you want to process user\'s avatar, it is advisable to utilize the ProcessPictureTool and input the qq of target user. If no extra description needed, just reply <EMPTY> at the next turn'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ export class SendVideoTool extends AbstractTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'Useful when you are allowed to send a video. You must use searchVideo to get search result and choose one video and get its id'
|
description = 'Useful when you are allowed to send a video. You must use searchVideo to get search result and choose one video and get its id. If no extra description needed, just reply <EMPTY> at the next turn'
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getBilibili (bvid) {
|
export async function getBilibili (bvid) {
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,5 @@ export class SendMessageToSpecificGroupOrUserTool extends AbstractTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'Useful when you want to send a text message to specific user or group'
|
description = 'Useful when you want to send a text message to specific user or group. If no extra description needed, just reply <EMPTY> at the next turn'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,5 @@ export class SendMusicTool extends AbstractTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'Useful when you want to share music. You must use searchMusic first to get the music id'
|
description = 'Useful when you want to share music. You must use searchMusic first to get the music id. If no extra description needed, just reply <EMPTY> at the next turn'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,5 +56,5 @@ export class SendPictureTool extends AbstractTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'Useful when you want to send one or more pictures.'
|
description = 'Useful when you want to send one or more pictures. If no extra description needed, just reply <EMPTY> at the next turn'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue