Skip to content

Commit 65d1188

Browse files
bincooobincooo
bincooo
authored and
bincooo
committed
style: g1.5 500错误处理
1 parent b332ca0 commit 65d1188

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21.6
55
require (
66
github.com/bincooo/claude-api v1.0.4-0.20240323131054-e8068584fb71
77
github.com/bincooo/cohere-api v0.0.0-20240408053055-744e6f22b310
8-
github.com/bincooo/coze-api v1.0.2-0.20240405081411-05cf25751abe
8+
github.com/bincooo/coze-api v1.0.2-0.20240409071705-1dbff01abec0
99
github.com/bincooo/edge-api v1.0.3-1.1630.0
1010
github.com/bincooo/goole15 v0.0.0-20240407113036-f089274aea02
1111
github.com/bincooo/sdio v0.0.0-20240307130432-7248b54caf4f

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/bincooo/claude-api v1.0.4-0.20240323131054-e8068584fb71 h1:+uDGlcGcL/
66
github.com/bincooo/claude-api v1.0.4-0.20240323131054-e8068584fb71/go.mod h1:qoD2FHwGq2+Ohl5xi+jFFYjAGxP0V1ImeIg6R05uqPQ=
77
github.com/bincooo/cohere-api v0.0.0-20240408053055-744e6f22b310 h1:NtvRGHhzEd5ZdxvPMgKVhV7gOT+cdUbcERvJR9n5ybE=
88
github.com/bincooo/cohere-api v0.0.0-20240408053055-744e6f22b310/go.mod h1:fi6FdO5X1gGcXNpn/6vGICraupaaoruMbDOIOtO5PZg=
9-
github.com/bincooo/coze-api v1.0.2-0.20240405081411-05cf25751abe h1:IitqcQim+NhhR5yP8otIf5iW5ryT2xvMB+rkm+ZZITk=
10-
github.com/bincooo/coze-api v1.0.2-0.20240405081411-05cf25751abe/go.mod h1:/BwOAxy8B8f/xwOKcGQd4qGgpj16M3XDdAqAf4s5pyc=
9+
github.com/bincooo/coze-api v1.0.2-0.20240409071705-1dbff01abec0 h1:alKDqG+5QY8ee2vBTf10H+1+3OgVbkZTQ+kKedzahkI=
10+
github.com/bincooo/coze-api v1.0.2-0.20240409071705-1dbff01abec0/go.mod h1:/BwOAxy8B8f/xwOKcGQd4qGgpj16M3XDdAqAf4s5pyc=
1111
github.com/bincooo/edge-api v1.0.3-1.1630.0 h1:VxEwnyazwNIhZaPpJdBGSQKvFbaAqBwPUllAMRGGD/0=
1212
github.com/bincooo/edge-api v1.0.3-1.1630.0/go.mod h1:KqUn1YF4q4FMy1I6Z3Zjq7qEoFQ9p4lbrFTJKcYwP5I=
1313
github.com/bincooo/goole15 v0.0.0-20240407113036-f089274aea02 h1:swXgl1MSN9sRKOmRY7B1aqAUkYlMAx6UIfHQ1dMdEKc=

internal/middle/coze/assembler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525

2626
// 8k
2727
botId8k = "7353047124357365778"
28-
version8k = "1712016843935"
28+
version8k = "1712645567468"
2929
scene8k = 2
3030

3131
// 128k

internal/middle/gemini/assembler.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,22 @@ func Complete15(ctx *gin.Context, req gpt.ChatCompletionRequest, matchers []comm
109109
opts.Temperature(req.Temperature)
110110
opts.TopP(req.TopP)
111111
opts.TopK(req.TopK)
112-
if c, ok := gkv[common.Hash(token)]; ok {
112+
h := common.Hash(token)
113+
if c, ok := gkv[h]; ok {
113114
opts.UA(c.userAgent)
114115
}
115116

116117
chat := goole.New(co, sign, auth, key, user, opts)
117118
ch, err := chat.Reply(ctx.Request.Context(), messages)
118119
if err != nil {
119120
code := -1
120-
if strings.Contains(err.Error(), "429 Too Many Requests") {
121+
errMessage := err.Error()
122+
if strings.Contains(errMessage, "429 Too Many Requests") {
121123
code = http.StatusTooManyRequests
122124
}
125+
if strings.Contains(errMessage, "500 Internal Server Error") {
126+
delete(gkv, h) // 尚不清楚 500 错误的原因
127+
}
123128
middle.ResponseWithE(ctx, code, err)
124129
return
125130
}
@@ -138,6 +143,7 @@ func extCookie15(ctx context.Context, token, proxies string) (sign, auth, key, u
138143
//
139144
} else if co, ok := gkv[h]; ok {
140145
opts = co
146+
logrus.Info("cookie: ", co.cookie)
141147
} else {
142148
s := strings.Split(token, "|")
143149
if len(s) < 4 {
@@ -199,6 +205,7 @@ func extCookie15(ctx context.Context, token, proxies string) (sign, auth, key, u
199205
}
200206

201207
cookie = opts.cookie
208+
logrus.Info("cookie: ", cookie)
202209
index := strings.Index(cookie, "[sign=")
203210
if index > -1 {
204211
end := strings.Index(cookie[index:], "]")

0 commit comments

Comments
 (0)