🐛 fix balance action error
This commit is contained in:
parent
fc284cc1f0
commit
ba654d8b81
@ -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()
|
||||||
|
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user