added modeltypes api
Former-commit-id: 5640bcde2019a2a174dbe84af5d802da2d1a4d99
This commit is contained in:
parent
b412019647
commit
63e6303152
|
@ -2,6 +2,18 @@ syntax = "v1"
|
||||||
|
|
||||||
type (
|
type (
|
||||||
/******************image inference*************************/
|
/******************image inference*************************/
|
||||||
|
ModelTypesResp {
|
||||||
|
ModelTypes []string `json:"types"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelNamesReq {
|
||||||
|
Type string `form:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelNamesResp {
|
||||||
|
ModelNames []string `json:"models"`
|
||||||
|
}
|
||||||
|
/******************image inference*************************/
|
||||||
|
|
||||||
ImageInferenceReq {
|
ImageInferenceReq {
|
||||||
TaskName string `form:"taskName"`
|
TaskName string `form:"taskName"`
|
||||||
|
@ -31,4 +43,5 @@ type (
|
||||||
Card string `json:"card"`
|
Card string `json:"card"`
|
||||||
ImageResult string `json:"imageResult"`
|
ImageResult string `json:"imageResult"`
|
||||||
}
|
}
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -909,6 +909,12 @@ service pcm {
|
||||||
service pcm {
|
service pcm {
|
||||||
@handler ImageInferenceHandler
|
@handler ImageInferenceHandler
|
||||||
post /inference/images (ImageInferenceReq) returns (ImageInferenceResp)
|
post /inference/images (ImageInferenceReq) returns (ImageInferenceResp)
|
||||||
|
|
||||||
|
@handler ModelTypesHandler
|
||||||
|
get /inference/modelTypes returns (ModelTypesResp)
|
||||||
|
|
||||||
|
@handler ModelNamesByTypeHandler
|
||||||
|
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@server(
|
@server(
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package inference
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ModelNamesByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ModelNamesReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := inference.NewModelNamesByTypeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ModelNamesByType(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package inference
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ModelTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
l := inference.NewModelTypesLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ModelTypes()
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1143,6 +1143,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/inference/images",
|
Path: "/inference/images",
|
||||||
Handler: inference.ImageInferenceHandler(serverCtx),
|
Handler: inference.ImageInferenceHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/inference/modelTypes",
|
||||||
|
Handler: inference.ModelTypesHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/inference/modelNames",
|
||||||
|
Handler: inference.ModelNamesByTypeHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package inference
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModelNamesByTypeLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewModelNamesByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelNamesByTypeLogic {
|
||||||
|
return &ModelNamesByTypeLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ModelNamesByTypeLogic) ModelNamesByType(req *types.ModelNamesReq) (resp *types.ModelNamesResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package inference
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModelTypesLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewModelTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModelTypesLogic {
|
||||||
|
return &ModelTypesLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ModelTypesLogic) ModelTypes() (resp *types.ModelTypesResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -5879,6 +5879,18 @@ type Category struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModelTypesResp struct {
|
||||||
|
ModelTypes []string `json:"types"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelNamesReq struct {
|
||||||
|
Type string `form:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelNamesResp struct {
|
||||||
|
ModelNames []string `json:"models"`
|
||||||
|
}
|
||||||
|
|
||||||
type ImageInferenceReq struct {
|
type ImageInferenceReq struct {
|
||||||
TaskName string `form:"taskName"`
|
TaskName string `form:"taskName"`
|
||||||
TaskDesc string `form:"taskDesc"`
|
TaskDesc string `form:"taskDesc"`
|
||||||
|
|
Loading…
Reference in New Issue