Browse Source

增加镜像的api接口

fix-2940
ychao_1983 3 years ago
parent
commit
6040996147
2 changed files with 24 additions and 0 deletions
  1. +22
    -0
      routers/repo/cloudbrain.go
  2. +2
    -0
      routers/routes/routes.go

+ 22
- 0
routers/repo/cloudbrain.go View File

@@ -1498,6 +1498,28 @@ func GetStarImages(ctx *context.Context) {

}

func GetModelArtsImages(ctx *context.Context) {
var engines modelarts.Engine
_ = json.Unmarshal([]byte(setting.Engines), &engines)
ctx.Data["engines"] = engines.Info

var versionInfos modelarts.VersionInfo
_ = json.Unmarshal([]byte(setting.EngineVersions), &versionInfos)
ctx.JSON(http.StatusOK, versionInfos.Version)

}

func GetC2netNpuImages(ctx *context.Context) {
images, err := grampus.GetImages(grampus.ProcessorTypeNPU)
if err != nil {
log.Error("GetImages failed:", err.Error())
ctx.JSON(http.StatusOK, []models.GrampusImage{})
} else {
ctx.JSON(http.StatusOK, images.Infos)
}

}

func getUID(ctx *context.Context) int64 {
var uid int64 = -1
if ctx.IsSigned {


+ 2
- 0
routers/routes/routes.go View File

@@ -353,6 +353,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/images/public", repo.GetPublicImages)
m.Get("/images/custom", repo.GetCustomImages)
m.Get("/images/star", repo.GetStarImages)
m.Get("/images/modelarts", repo.GetModelArtsImages)
m.Get("/images/c2netnpu", repo.GetC2netNpuImages)

m.Get("/repos", routers.ExploreRepos)
m.Get("/datasets", routers.ExploreDatasets)


Loading…
Cancel
Save