1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package aiser
- import (
- "encoding/json"
- "eta/eta_api/utils"
- "github.com/rdlucklib/rdluck_tools/http"
- )
- func ChatAutoMsg(prompt string) (result string, err error) {
- chatUrl := utils.EtaAiUrl + `/chat/auto_msg`
- param := make(map[string]interface{})
- param["Prompt"] = prompt
- postData, err := json.Marshal(param)
- if err != nil {
- return result, err
- }
- utils.FileLog.Info("postData:" + string(postData))
- body, err := http.HttpPost(chatUrl, string(postData), "application/json; charset=utf-8")
- if err != nil {
- return result, err
- }
- utils.FileLog.Info("result:" + string(body))
- resp := new(ChatAutoMsgResp)
- err = json.Unmarshal(body, &resp)
- if err != nil {
- return result, err
- }
- if resp.Ret != 200 {
- return resp.Msg, nil
- }
- result = resp.Data
- return result, nil
- }
- type ChatAutoMsgResp struct {
- Ret int
- Data string
- Msg string
- }
|