mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 05:17:10 +00:00
commit
676baffa20
2 changed files with 19 additions and 1 deletions
9
index.js
9
index.js
|
|
@ -2,6 +2,7 @@ import plugin from '../../lib/plugins/plugin.js'
|
|||
import { ChatGPTAPI } from 'chatgpt'
|
||||
import _ from 'lodash'
|
||||
const SESSION_TOKEN=''
|
||||
const blockWords = '屏蔽词1,屏蔽词2,屏蔽词3'
|
||||
|
||||
/**
|
||||
* 每个对话保留的时长。单个对话内ai是保留上下文的。超时后销毁对话,再次对话创建新的对话。
|
||||
|
|
@ -156,6 +157,14 @@ export class chatgpt extends plugin {
|
|||
utime: new Date(),
|
||||
num: previousConversation.num + 1
|
||||
}), { EX: CONVERSATION_PRESERVE_TIME })
|
||||
|
||||
// 检索是否有屏蔽词
|
||||
const blockWord = blockWords.split(',').find(word => response.toLowerCase().includes(word.toLowerCase()))
|
||||
if (blockWord) {
|
||||
await this.reply(`返回内容存在敏感词,我不想回答你`, true)
|
||||
return
|
||||
}
|
||||
|
||||
/** 最后回复消息 */
|
||||
await this.reply(`${response}`, e.isGroup)
|
||||
} catch (e) {
|
||||
|
|
|
|||
11
index_no#.js
11
index_no#.js
|
|
@ -2,6 +2,7 @@ import plugin from '../../lib/plugins/plugin.js'
|
|||
import { ChatGPTAPI } from 'chatgpt'
|
||||
import _ from 'lodash'
|
||||
const SESSION_TOKEN = ''
|
||||
const blockWords = '屏蔽词1,屏蔽词2,屏蔽词3'
|
||||
|
||||
/**
|
||||
* 每个对话保留的时长。单个对话内ai是保留上下文的。超时后销毁对话,再次对话创建新的对话。
|
||||
|
|
@ -162,6 +163,14 @@ export class chatgpt extends plugin {
|
|||
utime: new Date(),
|
||||
num: previousConversation.num + 1
|
||||
}), { EX: CONVERSATION_PRESERVE_TIME })
|
||||
|
||||
// 检索是否有屏蔽词
|
||||
const blockWord = blockWords.split(',').find(word => response.toLowerCase().includes(word.toLowerCase()))
|
||||
if (blockWord) {
|
||||
await this.reply(`返回内容存在敏感词,我不想回答你`, true)
|
||||
return
|
||||
}
|
||||
|
||||
/** 最后回复消息 */
|
||||
await this.reply(`${response}`, e.isGroup)
|
||||
} catch (e) {
|
||||
|
|
@ -169,4 +178,4 @@ export class chatgpt extends plugin {
|
|||
await this.reply(`与OpenAI通信异常,请稍后重试:${e}`, true, { recallMsg: e.isGroup ? 10 : 0 })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue