| @@ -63,7 +63,17 @@ type ( | |||||
| clusterName string `json:"clusterName"` | 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{ | |||||
| } | |||||
| ) | ) | ||||
| @@ -907,6 +907,9 @@ service pcm { | |||||
| group: inference | group: inference | ||||
| ) | ) | ||||
| service pcm { | service pcm { | ||||
| @handler TextToTextInferenceHandler | |||||
| post /inference/text (TextToTextInferenceReq) returns (TextToTextInferenceResp) | |||||
| @handler ImageInferenceHandler | @handler ImageInferenceHandler | ||||
| post /inference/images (ImageInferenceReq) returns (ImageInferenceResp) | post /inference/images (ImageInferenceReq) returns (ImageInferenceResp) | ||||
| @@ -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) | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1138,6 +1138,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | |||||
| server.AddRoutes( | server.AddRoutes( | ||||
| []rest.Route{ | []rest.Route{ | ||||
| { | |||||
| Method: http.MethodPost, | |||||
| Path: "/inference/text", | |||||
| Handler: inference.TextToTextInferenceHandler(serverCtx), | |||||
| }, | |||||
| { | { | ||||
| Method: http.MethodPost, | Method: http.MethodPost, | ||||
| Path: "/inference/images", | Path: "/inference/images", | ||||
| @@ -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 | |||||
| } | |||||
| @@ -5941,3 +5941,15 @@ type InferenceResult struct { | |||||
| Card string `json:"card"` | Card string `json:"card"` | ||||
| ClusterName string `json:"clusterName"` | 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 { | |||||
| } | |||||