fix: add modelarts of ai CheckModelExistence

This commit is contained in:
qiwang 2024-09-14 17:01:21 +08:00
parent 97d2af6f2d
commit 6dad353945
1 changed files with 28 additions and 1 deletions

View File

@ -812,10 +812,37 @@ func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mt
ModelName: name,
ModelType: mtype,
}
err := m.GetModelId(ctx, ifoption)
err := m.CheckImageExist(ctx, ifoption)
if err != nil {
return false
}
return true
}
func (m *ModelArtsLink) CheckImageExist(ctx context.Context, option *option.InferOption) error {
req := &modelarts.ListImagesReq{
Limit: m.pageSize,
Offset: m.pageIndex,
}
ListImageResp, err := m.modelArtsRpc.ListImages(ctx, req)
if err != nil {
return err
}
var modelName string
if ListImageResp.Code == 200 {
//return errors.New("failed to get ModelId")
for _, ListImage := range ListImageResp.Data {
if option.ModelName == "ChatGLM-6B" {
modelName = "chatglm-6b"
} else {
modelName = option.ModelName
}
if ListImage.Name == modelName {
return nil
}
}
}
return errors.New("failed to find Image ")
}