mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
feat: support claude api fix #659
This commit is contained in:
parent
8b2493a4bf
commit
79ab6cbd40
17 changed files with 859 additions and 563 deletions
|
|
@ -23,6 +23,7 @@ import VoiceVoxTTS, { supportConfigurations as voxRoleList } from '../utils/tts/
|
|||
import { supportConfigurations as azureRoleList } from '../utils/tts/microsoft-azure.js'
|
||||
import fetch from 'node-fetch'
|
||||
import { newFetch } from '../utils/proxy.js'
|
||||
import { createServer, runServer, stopServer } from '../server/index.js'
|
||||
|
||||
export class ChatgptManagement extends plugin {
|
||||
constructor (e) {
|
||||
|
|
@ -180,6 +181,11 @@ export class ChatgptManagement extends plugin {
|
|||
fnc: 'setAPIKey',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(claude|Claude)(Key|key)$',
|
||||
fnc: 'setClaudeKey',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(Gemini|gemini)(Key|key)$',
|
||||
fnc: 'setGeminiKey',
|
||||
|
|
@ -316,6 +322,11 @@ export class ChatgptManagement extends plugin {
|
|||
fnc: 'setXinghuoModel',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(claude|Claude)模型$',
|
||||
fnc: 'setClaudeModel',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt必应(禁用|禁止|关闭|启用|开启)搜索$',
|
||||
fnc: 'switchBingSearch',
|
||||
|
|
@ -330,6 +341,11 @@ export class ChatgptManagement extends plugin {
|
|||
reg: '^#chatgpt(开启|关闭)(api|API)流$',
|
||||
fnc: 'switchStream',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt(开启|关闭)(工具箱|后台服务)$',
|
||||
fnc: 'switchToolbox',
|
||||
permission: 'master'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
@ -1255,6 +1271,25 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
this.finish('saveAPIKey')
|
||||
}
|
||||
|
||||
async setClaudeKey (e) {
|
||||
this.setContext('saveClaudeKey')
|
||||
await this.reply('请发送Claude API Key', true)
|
||||
return false
|
||||
}
|
||||
|
||||
async saveClaudeKey () {
|
||||
if (!this.e.msg) return
|
||||
let token = this.e.msg
|
||||
if (!token.startsWith('sk-ant')) {
|
||||
await this.reply('Claude API Key格式错误。如果是格式特殊的非官方Key请前往锅巴或工具箱手动设置', true)
|
||||
this.finish('saveClaudeKey')
|
||||
return
|
||||
}
|
||||
Config.claudeKey = token
|
||||
await this.reply('Claude API Key设置成功', true)
|
||||
this.finish('saveClaudeKey')
|
||||
}
|
||||
|
||||
async setGeminiKey (e) {
|
||||
this.setContext('saveGeminiKey')
|
||||
await this.reply('请发送Gemini API Key.获取地址:https://makersuite.google.com/app/apikey', true)
|
||||
|
|
@ -1675,6 +1710,20 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
this.finish('saveAPIModel')
|
||||
}
|
||||
|
||||
async setClaudeModel (e) {
|
||||
this.setContext('saveClaudeModel')
|
||||
await this.reply('请发送Claude模型,官方推荐模型:\nclaude-3-opus-20240229\nclaude-3-sonnet-20240229', true)
|
||||
return false
|
||||
}
|
||||
|
||||
async saveClaudeModel () {
|
||||
if (!this.e.msg) return
|
||||
let token = this.e.msg
|
||||
Config.claudeApiModel = token
|
||||
await this.reply('Claude模型设置成功', true)
|
||||
this.finish('saveClaudeModel')
|
||||
}
|
||||
|
||||
async setOpenAiBaseUrl (e) {
|
||||
this.setContext('saveOpenAiBaseUrl')
|
||||
await this.reply('请发送API反代', true)
|
||||
|
|
@ -1775,4 +1824,25 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
await this.reply('好的,已经关闭API流式输出')
|
||||
}
|
||||
}
|
||||
|
||||
async switchToolbox (e) {
|
||||
if (e.msg.includes('开启')) {
|
||||
if (Config.enableToolbox) {
|
||||
await this.reply('已经开启了')
|
||||
return
|
||||
}
|
||||
Config.enableToolbox = true
|
||||
await this.reply('开启中', true)
|
||||
await runServer()
|
||||
await this.reply('好的,已经打开工具箱')
|
||||
} else {
|
||||
if (!Config.enableToolbox) {
|
||||
await this.reply('已经是关闭的了')
|
||||
return
|
||||
}
|
||||
Config.enableToolbox = false
|
||||
await stopServer()
|
||||
await this.reply('好的,已经关闭工具箱')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue