mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: simple random load balance for claude api key
This commit is contained in:
parent
7d83c34e98
commit
3b5a26ce62
2 changed files with 54 additions and 15 deletions
|
|
@ -46,7 +46,10 @@ const BASEURL = 'https://api.anthropic.com'
|
|||
* input_tokens: number,
|
||||
* output_tokens: number,
|
||||
* }>} usage
|
||||
*
|
||||
* @property {{
|
||||
* type: string,
|
||||
* message: string,
|
||||
* }} error
|
||||
* Claude响应的基本格式
|
||||
*/
|
||||
|
||||
|
|
@ -172,6 +175,10 @@ export class ClaudeAPIClient extends BaseClient {
|
|||
if (this.debug) {
|
||||
console.log(JSON.stringify(response))
|
||||
}
|
||||
if (response.type === 'error') {
|
||||
logger.error(response.error.message)
|
||||
throw new Error(response.error.type)
|
||||
}
|
||||
await this.upsertMessage(thisMessage)
|
||||
const respMessage = Object.assign(response, {
|
||||
id: idModel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue