feat: 添加星火支持(beta)

This commit is contained in:
ikechan8370 2023-05-12 20:11:08 +08:00
parent 76f0328a8e
commit 926f07c8e9
7 changed files with 268 additions and 5 deletions

View file

@ -102,6 +102,11 @@ export class ChatgptManagement extends plugin {
fnc: 'useSlackClaudeBasedSolution',
permission: 'master'
},
{
reg: '^#chatgpt切换星火$',
fnc: 'useXinghuoBasedSolution',
permission: 'master'
},
{
reg: '^#chatgpt(必应|Bing)切换',
fnc: 'changeBingTone',
@ -149,6 +154,11 @@ export class ChatgptManagement extends plugin {
fnc: 'setAPIPromptPrefix',
permission: 'master'
},
{
reg: '^#chatgpt设置星火token',
fnc: 'setXinghuoToken',
permission: 'master'
},
{
reg: '^#chatgpt设置(Bing|必应|Sydney|悉尼|sydney|bing)设定',
fnc: 'setBingPromptPrefix',
@ -805,6 +815,16 @@ export class ChatgptManagement extends plugin {
}
}
async useXinghuoBasedSolution () {
let use = await redis.get('CHATGPT:USE')
if (use !== 'xh') {
await redis.set('CHATGPT:USE', 'xh')
await this.reply('已切换到基于星火的解决方案')
} else {
await this.reply('当前已经是星火模式了')
}
}
async changeBingTone (e) {
let tongStyle = e.msg.replace(/^#chatgpt(必应|Bing)切换/, '')
if (!tongStyle) {
@ -1083,6 +1103,21 @@ export class ChatgptManagement extends plugin {
this.finish('saveAPIKey')
}
async setXinghuoToken () {
this.setContext('saveXinghuoToken')
await this.reply('请发送星火的ssoSessionId', true)
return false
}
async saveXinghuoToken () {
if (!this.e.msg) return
let token = this.e.msg
// todo
Config.xinghuoToken = token
await this.reply('星火ssoSessionId设置成功', true)
this.finish('saveXinghuoToken')
}
async setAPIPromptPrefix (e) {
this.setContext('saveAPIPromptPrefix')
await this.reply('请发送用于API模式的设定', true)