File size: 671 Bytes
c5eab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package monica

import (
	"context"
	"github.com/go-resty/resty/v2"
	"log"
	"monica-proxy/internal/config"
	"monica-proxy/internal/types"
	"monica-proxy/internal/utils"
)

// SendMonicaRequest 发起对 Monica AI 的请求(使用 resty)
func SendMonicaRequest(ctx context.Context, mReq *types.MonicaRequest) (*resty.Response, error) {
	// 发起请求
	resp, err := utils.RestySSEClient.R().
		SetContext(ctx).
		SetHeader("cookie", config.MonicaConfig.MonicaCookie).
		SetBody(mReq).
		Post(types.BotChatURL)

	if err != nil {
		log.Printf("monica API error: %v", err)
		return nil, err
	}

	// 如果需要在这里做更多判断,可自行补充
	return resp, nil
}