forked from JointCloud/pcm-modelarts
35 lines
816 B
Go
35 lines
816 B
Go
package modelartsservicelogic
|
|
|
|
import (
|
|
"bytes"
|
|
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
|
|
"k8s.io/apimachinery/pkg/util/json"
|
|
"log"
|
|
)
|
|
|
|
type ChatglmReq struct {
|
|
Promt string `json:"promt,omitempty"`
|
|
Platform string `json:"platform,omitempty"`
|
|
ServiceId string `json:"service_id,omitempty"`
|
|
}
|
|
|
|
type ChatglmResp struct {
|
|
}
|
|
|
|
// 文本推理 Chatglm
|
|
func ChatglmReasoning(req ChatglmReq) (ChatglmResp, error) {
|
|
var resp ChatglmResp
|
|
platform, err := util.GetModelArtsConfWithPlatform(req.Platform)
|
|
if err != nil {
|
|
log.Print(err)
|
|
}
|
|
reqByte, err := json.Marshal(req)
|
|
body, err := util.SendRequest("POST", platform.Endpoint+"v1/infers/"+req.ServiceId+"/image",
|
|
bytes.NewBuffer(reqByte), req.Platform)
|
|
if err != nil {
|
|
log.Print(err)
|
|
}
|
|
json.Unmarshal(*body, &resp)
|
|
return resp, nil
|
|
}
|