mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
Merge branch 'feature/ai-balance' into 'main'
fix: ai key sort See merge request apipark/APIPark!149
This commit is contained in:
@@ -416,7 +416,7 @@ func (i *imlKeyModule) Sort(ctx context.Context, providerId string, input *ai_ke
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := i.aiKeyService.List(ctx)
|
||||
list, err := i.aiKeyService.KeysByProvider(ctx, providerId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ type ConfiguredProviderItem struct {
|
||||
}
|
||||
|
||||
type KeyStatus struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Priority int `json:"-"`
|
||||
}
|
||||
|
||||
type ProviderItem struct {
|
||||
|
||||
+7
-3
@@ -185,11 +185,15 @@ func (i *imlProviderModule) ConfiguredProviders(ctx context.Context) ([]*ai_dto.
|
||||
status = ai_key_dto.KeyError
|
||||
}
|
||||
keysStatus = append(keysStatus, &ai_dto.KeyStatus{
|
||||
Id: k.ID,
|
||||
Name: k.Name,
|
||||
Status: status.String(),
|
||||
Id: k.ID,
|
||||
Name: k.Name,
|
||||
Status: status.String(),
|
||||
Priority: k.Priority,
|
||||
})
|
||||
}
|
||||
sort.Slice(keysStatus, func(i, j int) bool {
|
||||
return keysStatus[i].Priority < keysStatus[j].Priority
|
||||
})
|
||||
|
||||
providers = append(providers, &ai_dto.ConfiguredProviderItem{
|
||||
Id: l.Id,
|
||||
|
||||
Reference in New Issue
Block a user