mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-14 20:23:46 +08:00
♻️ refactor: 重构http请求函数
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package closeai
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"one-api/common"
|
||||
"one-api/model"
|
||||
@@ -19,9 +20,9 @@ func (p *CloseaiProxyProvider) Balance(channel *model.Channel) (float64, error)
|
||||
|
||||
// 发送请求
|
||||
var response OpenAICreditGrants
|
||||
err = client.SendRequest(req, &response)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
_, errWithCode := common.SendRequest(req, &response, false)
|
||||
if errWithCode != nil {
|
||||
return 0, errors.New(errWithCode.OpenAIError.Message)
|
||||
}
|
||||
|
||||
channel.UpdateBalance(response.TotalAvailable)
|
||||
|
||||
Reference in New Issue
Block a user