Browse Source

added textinference api

Former-commit-id: d32678e386
pull/244/head
tzwang 1 year ago
parent
commit
1ee960f52a
6 changed files with 89 additions and 1 deletions
  1. +11
    -1
      api/desc/inference/inference.api
  2. +3
    -0
      api/desc/pcm.api
  3. +28
    -0
      api/internal/handler/inference/texttotextinferencehandler.go
  4. +5
    -0
      api/internal/handler/routes.go
  5. +30
    -0
      api/internal/logic/inference/texttotextinferencelogic.go
  6. +12
    -0
      api/internal/types/types.go

+ 11
- 1
api/desc/inference/inference.api View File

@@ -63,7 +63,17 @@ type (
clusterName string `json:"clusterName"`
}

/******************TextToText inference*************************/
TextToTextInferenceReq{
TaskName string `form:"taskName"`
TaskDesc string `form:"taskDesc"`
ModelName string `form:"modelName"`
ModelType string `form:"modelType"`
AdapterId string `form:"adapterId"`
ClusterId string `form:"clusterIds"`
}
TextToTextInferenceResp{


}

)

+ 3
- 0
api/desc/pcm.api View File

@@ -907,6 +907,9 @@ service pcm {
group: inference
)
service pcm {
@handler TextToTextInferenceHandler
post /inference/text (TextToTextInferenceReq) returns (TextToTextInferenceResp)

@handler ImageInferenceHandler
post /inference/images (ImageInferenceReq) returns (ImageInferenceResp)



+ 28
- 0
api/internal/handler/inference/texttotextinferencehandler.go View File

@@ -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 TextToTextInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TextToTextInferenceReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := inference.NewTextToTextInferenceLogic(r.Context(), svcCtx)
resp, err := l.TextToTextInference(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

+ 5
- 0
api/internal/handler/routes.go View File

@@ -1138,6 +1138,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {

server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/inference/text",
Handler: inference.TextToTextInferenceHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/inference/images",


+ 30
- 0
api/internal/logic/inference/texttotextinferencelogic.go View File

@@ -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 TextToTextInferenceLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewTextToTextInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TextToTextInferenceLogic {
return &TextToTextInferenceLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *TextToTextInferenceLogic) TextToTextInference(req *types.TextToTextInferenceReq) (resp *types.TextToTextInferenceResp, err error) {
// todo: add your logic here and delete this line

return
}

+ 12
- 0
api/internal/types/types.go View File

@@ -5941,3 +5941,15 @@ type InferenceResult struct {
Card string `json:"card"`
ClusterName string `json:"clusterName"`
}

type TextToTextInferenceReq struct {
TaskName string `form:"taskName"`
TaskDesc string `form:"taskDesc"`
ModelName string `form:"modelName"`
ModelType string `form:"modelType"`
AdapterId string `form:"adapterId"`
ClusterId string `form:"clusterIds"`
}

type TextToTextInferenceResp struct {
}

Loading…
Cancel
Save