🐛 fix balance action error

This commit is contained in:
Martial BE 2023-12-29 17:55:05 +08:00
parent fc284cc1f0
commit ba654d8b81
No known key found for this signature in database
GPG Key ID: D06C32DF0EDB9084
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) { func (p *OpenAIProvider) Balance(channel *model.Channel) (float64, error) {
if !p.BalanceAction {
return 0, errors.New("不支持余额查询")
}
fullRequestURL := p.GetFullRequestURL("/v1/dashboard/billing/subscription", "") fullRequestURL := p.GetFullRequestURL("/v1/dashboard/billing/subscription", "")
headers := p.GetRequestHeaders() headers := p.GetRequestHeaders()

View File

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

View File

@ -136,7 +136,7 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
</TableCell> </TableCell>
<TableCell> <TableCell>
<Tooltip title={'点击更新余额'} placement="top" onClick={updateChannelBalance}> <Tooltip title={'点击更新余额'} placement="top" onClick={updateChannelBalance}>
{renderBalance(itemBalance)} {renderBalance(item.type, itemBalance)}
</Tooltip> </Tooltip>
</TableCell> </TableCell>
<TableCell> <TableCell>