🐛 fix balance action error

This commit is contained in:
Martial BE
2023-12-29 17:55:05 +08:00
parent fc284cc1f0
commit ba654d8b81
3 changed files with 12 additions and 4 deletions

View File

@@ -9,6 +9,10 @@ import (
)
func (p *OpenAIProvider) Balance(channel *model.Channel) (float64, error) {
if !p.BalanceAction {
return 0, errors.New("不支持余额查询")
}
fullRequestURL := p.GetFullRequestURL("/v1/dashboard/billing/subscription", "")
headers := p.GetRequestHeaders()

View File

@@ -20,12 +20,15 @@ type OpenAIProviderFactory struct{}
// 创建 OpenAIProvider
func (f OpenAIProviderFactory) Create(c *gin.Context) base.ProviderInterface {
return CreateOpenAIProvider(c, "")
openAIProvider := CreateOpenAIProvider(c, "")
openAIProvider.BalanceAction = true
return openAIProvider
}
type OpenAIProvider struct {
base.BaseProvider
IsAzure bool
IsAzure bool
BalanceAction bool
}
// 创建 OpenAIProvider
@@ -50,7 +53,8 @@ func CreateOpenAIProvider(c *gin.Context, baseURL string) *OpenAIProvider {
ImagesVariations: "/v1/images/variations",
Context: c,
},
IsAzure: false,
IsAzure: false,
BalanceAction: false,
}
}