pcm-modelarts/internal/logic/modelartsservice/chatglmreasoninglogic.go

45 lines
1.2 KiB
Go

package modelartsservicelogic
import (
"bytes"
"context"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"k8s.io/apimachinery/pkg/util/json"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/svc"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"github.com/zeromicro/go-zero/core/logx"
)
type ChatglmReasoningLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewChatglmReasoningLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatglmReasoningLogic {
return &ChatglmReasoningLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ChatglmReasoningLogic) ChatglmReasoning(in *modelarts.ChatglmReasoningReq) (*modelarts.ChatglmReasoningResp, error) {
// todo: add your logic here and delete this line
var resp modelarts.ChatglmReasoningResp
platform, err := util.GetModelArtsConfWithPlatform(in.Platform)
if err != nil {
return nil, err
}
reqByte, err := json.Marshal(in)
body, err := util.SendRequest("POST", platform.Endpoint+"v1/infers/"+in.ServiceId+"/chat",
bytes.NewBuffer(reqByte), in.Platform)
if err != nil {
return nil, err
}
json.Unmarshal(*body, &resp)
return &resp, nil
}