mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: recall; change style
This commit is contained in:
parent
85b0d68e7e
commit
e5f0ada32e
3 changed files with 41 additions and 30 deletions
48
apps/chat.js
48
apps/chat.js
|
|
@ -79,13 +79,14 @@ export class chatgpt extends plugin {
|
|||
markdown: true,
|
||||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
|
||||
})
|
||||
logger.info('chatgpt插件已加载')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取chatgpt当前对话列表
|
||||
* @param e
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
* 获取chatgpt当前对话列表
|
||||
* @param e
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async getConversations (e) {
|
||||
let keys = await redis.keys('CHATGPT:CONVERSATIONS:*')
|
||||
if (!keys || keys.length === 0) {
|
||||
|
|
@ -104,10 +105,10 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* 销毁指定人的对话
|
||||
* @param e
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
* 销毁指定人的对话
|
||||
* @param e
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async destroyConversations (e) {
|
||||
let ats = e.message.filter(m => m.type === 'at')
|
||||
if (ats.length === 0) {
|
||||
|
|
@ -134,11 +135,11 @@ export class chatgpt extends plugin {
|
|||
|
||||
async help (e) {
|
||||
let response = 'chatgpt-plugin使用帮助文字版\n' +
|
||||
'@我+聊天内容: 发起对话与AI进行聊天\n' +
|
||||
'#chatgpt对话列表: 查看当前发起的对话\n' +
|
||||
'#结束对话: 结束自己或@用户的对话\n' +
|
||||
'#chatgpt帮助: 查看本帮助\n' +
|
||||
'源代码:https://github.com/ikechan8370/chatgpt-plugin'
|
||||
'@我+聊天内容: 发起对话与AI进行聊天\n' +
|
||||
'#chatgpt对话列表: 查看当前发起的对话\n' +
|
||||
'#结束对话: 结束自己或@用户的对话\n' +
|
||||
'#chatgpt帮助: 查看本帮助\n' +
|
||||
'源代码:https://github.com/ikechan8370/chatgpt-plugin'
|
||||
await this.reply(response)
|
||||
}
|
||||
|
||||
|
|
@ -167,9 +168,9 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* #chatgpt
|
||||
* @param e oicq传递的事件参数e
|
||||
*/
|
||||
* #chatgpt
|
||||
* @param e oicq传递的事件参数e
|
||||
*/
|
||||
async chatgpt (e) {
|
||||
if (!e.msg || e.msg.startsWith('#')) {
|
||||
return
|
||||
|
|
@ -188,7 +189,7 @@ export class chatgpt extends plugin {
|
|||
await this.reply(`OpenAI认证失败,请检查Token:${e}`, true)
|
||||
return
|
||||
}
|
||||
await this.reply('我正在思考如何回复你,请稍等', true, 5)
|
||||
await this.reply('我正在思考如何回复你,请稍等', true, { recallMsg: 5 })
|
||||
let c
|
||||
logger.info(`chatgpt question: ${question}`)
|
||||
let previousConversation = await redis.get(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)
|
||||
|
|
@ -239,11 +240,14 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
}
|
||||
if (userSetting.usePicture) {
|
||||
while (!response.trimEnd().endsWith('.') && !response.trimEnd().endsWith('。') && !response.trimEnd().endsWith('……') &&
|
||||
!response.trimEnd().endsWith('!') && !response.trimEnd().endsWith('!') && !response.trimEnd().endsWith(']') && !response.trimEnd().endsWith('】')
|
||||
) {
|
||||
await this.reply('内容有点多,我正在奋笔疾书,请再等一会', true, 5)
|
||||
let endTokens = ['.', '。', '……', '!', '!', ']', ')', ')', '】', '?', '?', '~']
|
||||
while (!endTokens.find(token => response.trimEnd().endsWith(token))) {
|
||||
// while (!response.trimEnd().endsWith('.') && !response.trimEnd().endsWith('。') && !response.trimEnd().endsWith('……') &&
|
||||
// !response.trimEnd().endsWith('!') && !response.trimEnd().endsWith('!') && !response.trimEnd().endsWith(']') && !response.trimEnd().endsWith('】')
|
||||
// ) {
|
||||
await this.reply('内容有点多,我正在奋笔疾书,请再等一会', true, { recallMsg: 5 })
|
||||
const responseAppend = await c.sendMessage('Continue')
|
||||
// console.log(responseAppend)
|
||||
// 检索是否有屏蔽词
|
||||
const blockWord = blockWords.split(',').find(word => responseAppend.toLowerCase().includes(word.toLowerCase()))
|
||||
if (blockWord) {
|
||||
|
|
@ -251,7 +255,7 @@ export class chatgpt extends plugin {
|
|||
return
|
||||
}
|
||||
if (responseAppend.indexOf('conversation') > -1 || responseAppend.startsWith("I'm sorry")) {
|
||||
logger.warn('chatgpt might forgot what it had said')
|
||||
logger.warn('chatgpt might forget what it had said')
|
||||
break
|
||||
}
|
||||
// 更新redis中的conversation对象,因为send后c已经被自动更新了
|
||||
|
|
|
|||
|
|
@ -36,23 +36,27 @@ body {
|
|||
margin-bottom: 5px;
|
||||
}
|
||||
.question {
|
||||
background: #009FFF; /* fallback for old browsers */
|
||||
background: -webkit-linear-gradient(to right, #ec2F4B, #009FFF); /* Chrome 10-25, Safari 5.1-6 */
|
||||
background: linear-gradient(to right, #ec2F4B, #009FFF); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
|
||||
color: #000000;
|
||||
text-shadow: 0 0 10px white;
|
||||
font-weight: bold;
|
||||
background: #C6FFDD; /* fallback for old browsers */
|
||||
background: -webkit-linear-gradient(to right, #f7797d, #FBD786, #C6FFDD); /* Chrome 10-25, Safari 5.1-6 */
|
||||
background: linear-gradient(to right, #f7797d, #FBD786, #C6FFDD); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
|
||||
border-radius: 5px;
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 10px;
|
||||
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
|
||||
}
|
||||
.question span {
|
||||
color: #000000;
|
||||
/*text-shadow: 0 0 10px white;*/
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.answer {
|
||||
position: relative;
|
||||
border-radius: 5px;
|
||||
padding: 8px 10px;
|
||||
background: #dbe9ff;
|
||||
width: 100%;
|
||||
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
<!-- {{senderName}}-->
|
||||
<!-- </div>-->
|
||||
<div class="question">
|
||||
{{question}}
|
||||
<span>
|
||||
{{question}}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class="answer">
|
||||
<div id="content">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue