fix: provider status incorrect

This commit is contained in:
Liujian
2024-12-31 14:48:19 +08:00
parent 30da6e10a1
commit a307917b66
3 changed files with 23 additions and 21 deletions
+5 -5
View File
@@ -13,9 +13,9 @@ func (p ProviderStatus) Int() int {
case ProviderAbnormal:
return 2
case ProviderEnabled:
return 0
case ProviderDisabled:
return 1
case ProviderDisabled:
return 0
default:
return 1
}
@@ -30,10 +30,10 @@ func ToProviderStatus(status int) ProviderStatus {
case 2:
return ProviderAbnormal
case 0:
return ProviderEnabled
return ProviderDisabled
case 1:
return ProviderDisabled
return ProviderEnabled
default:
return ProviderDisabled
return ProviderEnabled
}
}
+2 -1
View File
@@ -17,10 +17,11 @@ type Provider struct {
Name string `json:"name"`
Config string `json:"config"`
GetAPIKeyUrl string `json:"get_apikey_url"`
DefaultLLM string `json:"defaultLLM"`
DefaultLLM string `json:"default_llm"`
DefaultLLMConfig string `json:"-"`
Priority int `json:"priority"`
Status ProviderStatus `json:"status"`
Configured bool `json:"configured"`
}
type ConfiguredProviderItem struct {
+16 -15
View File
@@ -391,6 +391,7 @@ func (i *imlProviderModule) Provider(ctx context.Context, id string) (*ai_dto.Pr
DefaultLLMConfig: defaultLLM.DefaultConfig(),
Priority: info.Priority,
Status: ai_dto.ProviderEnabled,
Configured: true,
}, nil
}
@@ -589,21 +590,21 @@ func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string,
log.Errorf("unmarshal ai provider config error,id is %s,err is %v", id, err)
return err
}
return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
{
BasicItem: &gateway.BasicItem{
ID: id,
Description: info.Name,
Resource: id,
Version: info.UpdateAt.Format("20060102150405"),
MatchLabels: map[string]string{
"module": "ai-provider",
},
},
Attr: cfg,
}, newAIUpstream(id, p.URI()),
}, true)
return nil
//return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
// {
// BasicItem: &gateway.BasicItem{
// ID: id,
// Description: info.Name,
// Resource: id,
// Version: info.UpdateAt.Format("20060102150405"),
// MatchLabels: map[string]string{
// "module": "ai-provider",
// },
// },
// Attr: cfg,
// }, newAIUpstream(id, p.URI()),
//}, true)
})
}