mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-16 05:03:44 +08:00
🐛 fix balance action error
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Tooltip title={'点击更新余额'} placement="top" onClick={updateChannelBalance}>
|
||||
{renderBalance(itemBalance)}
|
||||
{renderBalance(item.type, itemBalance)}
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
|
||||
Reference in New Issue
Block a user