|
|
@@ -586,3 +586,53 @@ func ModifyModelInfo(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func QueryModelListForPredict(ctx *context.Context) { |
|
|
|
repoId := ctx.Repo.Repository.ID |
|
|
|
modelResult, count, err := models.QueryModel(&models.AiModelQueryOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: -1, |
|
|
|
PageSize: -1, |
|
|
|
}, |
|
|
|
RepoID: repoId, |
|
|
|
Type: -1, |
|
|
|
New: -1, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("Cloudbrain", err) |
|
|
|
return |
|
|
|
} |
|
|
|
log.Info("query return count=" + fmt.Sprint(count)) |
|
|
|
|
|
|
|
nameList := make([]string, 0) |
|
|
|
|
|
|
|
nameMap := make(map[string][]*models.AiModelManage) |
|
|
|
for _, model := range modelResult { |
|
|
|
if _, value := nameMap[model.Name]; !value { |
|
|
|
models := make([]*models.AiModelManage, 0) |
|
|
|
models = append(models, model) |
|
|
|
nameMap[model.Name] = models |
|
|
|
nameList = append(nameList, model.Name) |
|
|
|
} else { |
|
|
|
nameMap[model.Name] = append(nameMap[model.Name], model) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mapInterface := make(map[string]interface{}) |
|
|
|
mapInterface["nameList"] = nameList |
|
|
|
mapInterface["nameMap"] = nameMap |
|
|
|
ctx.JSON(http.StatusOK, mapInterface) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryModelFileForPredict(ctx *context.Context) { |
|
|
|
id := ctx.Query("ID") |
|
|
|
model, err := models.QueryModelById(id) |
|
|
|
if err != nil { |
|
|
|
log.Error("no such model!", err.Error()) |
|
|
|
ctx.ServerError("no such model:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
prefix := model.Path[len(setting.Bucket)+1:] |
|
|
|
fileinfos, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix) |
|
|
|
ctx.JSON(http.StatusOK, fileinfos) |
|
|
|
} |