mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
Merge branch 'v2' of github.com:ikechan8370/chatgpt-plugin into v2
This commit is contained in:
commit
83c481a4bc
3 changed files with 9 additions and 8 deletions
|
|
@ -2,7 +2,8 @@ import { Config } from '../utils/config.js'
|
|||
import { getChatHistoryGroup } from '../utils/chat.js'
|
||||
import { convertFaces } from '../utils/face.js'
|
||||
import { customSplitRegex, filterResponseChunk } from '../utils/text.js'
|
||||
import core from '../model/core.js'
|
||||
import core, {roleMap} from '../model/core.js'
|
||||
import {formatDate} from '../utils/common.js'
|
||||
|
||||
export class bym extends plugin {
|
||||
constructor () {
|
||||
|
|
@ -54,13 +55,13 @@ export class bym extends plugin {
|
|||
}
|
||||
if (prop < Config.bymRate) {
|
||||
logger.info('random chat hit')
|
||||
let chats = await getChatHistoryGroup(e, 20)
|
||||
let chats = await getChatHistoryGroup(e, Config.groupContextLength)
|
||||
let system = `你的名字是“${Config.assistantLabel}”,你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。如果此时不需要自己说话,可以只回复<EMPTY>` +
|
||||
candidate +
|
||||
'以下是聊天记录:' + chats
|
||||
.map(chat => {
|
||||
let sender = chat.sender || chat || {}
|
||||
return `${sender.card || sender.nickname}(${sender.user_id}) :${chat.raw_message}`
|
||||
return `【${sender.card || sender.nickname}】(qq:${sender.user_id}, ${roleMap[sender.role] || 'normal user'},${sender.area ? 'from ' + sender.area + ', ' : ''} ${sender.age} years old, 群头衔:${sender.title}, gender: ${sender.sex}, time:${formatDate(new Date(chat.time * 1000))} 说:${chat.raw_message}`
|
||||
})
|
||||
.join('\n') +
|
||||
`\n你的回复应该尽可能简练,像人类一样随意,不要附加任何奇怪的东西,如聊天记录的格式(比如${Config.assistantLabel}:),禁止重复聊天记录。`
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import { BingAIClient } from '../client/CopilotAIClient.js'
|
|||
import Keyv from 'keyv'
|
||||
import crypto from 'crypto'
|
||||
|
||||
const roleMap = {
|
||||
export const roleMap = {
|
||||
owner: 'group owner',
|
||||
admin: 'group administrator'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ export async function getChatHistoryGroup (e, num) {
|
|||
if (!chatHistory || chatHistory.length === 0) {
|
||||
break
|
||||
}
|
||||
chats.push(...chatHistory)
|
||||
if (seq === chatHistory[0].seq || seq === chatHistory[0].message_id) {
|
||||
chats.push(...chatHistory.reverse())
|
||||
if (seq === chatHistory[chatHistory.length - 1].seq || seq === chatHistory[chatHistory.length - 1].message_id) {
|
||||
break
|
||||
}
|
||||
seq = chatHistory[0].seq || chatHistory[0].message_id
|
||||
seq = chatHistory[chatHistory.length - 1].seq || chatHistory[chatHistory.length - 1].message_id
|
||||
}
|
||||
chats = chats.slice(0, num)
|
||||
chats = chats.slice(0, num).reverse()
|
||||
try {
|
||||
let mm = await e.bot.gml
|
||||
for (const chat of chats) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue