diff --git a/api/desc/inference/inference.api b/api/desc/inference/inference.api index ba9b1946..1872d2c6 100644 --- a/api/desc/inference/inference.api +++ b/api/desc/inference/inference.api @@ -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{ - + } ) diff --git a/api/desc/pcm.api b/api/desc/pcm.api index b912fda9..0a7b51bf 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -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) diff --git a/api/internal/handler/inference/texttotextinferencehandler.go b/api/internal/handler/inference/texttotextinferencehandler.go new file mode 100644 index 00000000..55df289c --- /dev/null +++ b/api/internal/handler/inference/texttotextinferencehandler.go @@ -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) + } + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index e04c7750..2daff30f 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -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", diff --git a/api/internal/logic/inference/texttotextinferencelogic.go b/api/internal/logic/inference/texttotextinferencelogic.go new file mode 100644 index 00000000..faf61301 --- /dev/null +++ b/api/internal/logic/inference/texttotextinferencelogic.go @@ -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 +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 86f165bd..b2a942da 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -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 { +}