fix: add modelarts of ai CheckModelExistence
This commit is contained in:
parent
97d2af6f2d
commit
6dad353945
|
@ -812,10 +812,37 @@ func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mt
|
||||||
ModelName: name,
|
ModelName: name,
|
||||||
ModelType: mtype,
|
ModelType: mtype,
|
||||||
}
|
}
|
||||||
err := m.GetModelId(ctx, ifoption)
|
err := m.CheckImageExist(ctx, ifoption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
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 ")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue