fix: recall; change style

This commit is contained in:
葛胤池 2022-12-11 13:38:37 +08:00
parent 85b0d68e7e
commit e5f0ada32e
3 changed files with 41 additions and 30 deletions

View file

@ -79,6 +79,7 @@ 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插件已加载')
}
/**
@ -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已经被自动更新了

View file

@ -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 {

View file

@ -15,7 +15,10 @@
<!-- {{senderName}}-->
<!-- </div>-->
<div class="question">
<span>
{{question}}
</span>
</div>
<div class="answer">
<div id="content">