coo7 commited on
Commit
4930319
·
verified ·
1 Parent(s): 4267ace

Create monica/client.go

Browse files
Files changed (1) hide show
  1. internal/monica/client.go +28 -0
internal/monica/client.go ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package monica
2
+
3
+ import (
4
+ "context"
5
+ "github.com/go-resty/resty/v2"
6
+ "log"
7
+ "monica-proxy/internal/config"
8
+ "monica-proxy/internal/types"
9
+ "monica-proxy/internal/utils"
10
+ )
11
+
12
+ // SendMonicaRequest 发起对 Monica AI 的请求(使用 resty)
13
+ func SendMonicaRequest(ctx context.Context, mReq *types.MonicaRequest) (*resty.Response, error) {
14
+ // 发起请求
15
+ resp, err := utils.RestySSEClient.R().
16
+ SetContext(ctx).
17
+ SetHeader("cookie", config.MonicaConfig.MonicaCookie).
18
+ SetBody(mReq).
19
+ Post(types.BotChatURL)
20
+
21
+ if err != nil {
22
+ log.Printf("monica API error: %v", err)
23
+ return nil, err
24
+ }
25
+
26
+ // 如果需要在这里做更多判断,可自行补充
27
+ return resp, nil
28
+ }