ai365vip / chat-api

基于One API与New API的基础上进行二次开发
https://api.ai365vip.com/
Other
278 stars 67 forks source link

遇到空返回会报错invalid memory address or nil pointer dereference #44

Open luomo-pro opened 1 month ago

luomo-pro commented 1 month ago

例行检查

问题描述 添加了一个openai的渠道(但不是官方,是第三方平台的) 重试次数设置成3,并且开启空返回重试。 发现有时候回复是空的,就会报错,在错误日志里看到了如下信息: [ERR] 2024/05/27 - 20:02:43 | 20240527200242925715450k3AZufbs | panic detected: runtime error: invalid memory address or nil pointer dereference [ERR] 2024/05/27 - 20:02:43 | 20240527200242925715450k3AZufbs | stacktrace from panic: goroutine 67681 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x5e one-api/router.SetRelayRouter.RelayPanicRecover.func2.1() /build/middleware/recover.go:18 +0xc5 panic({0x10bf340?, 0x3a8dd70?}) /usr/local/go/src/runtime/panic.go:770 +0x132 one-api/relay/channel/openai.ErrorWrapper({0x0?, 0x0?}, {0x12271d1, 0x1e}, 0x1f4) /build/relay/channel/openai/util.go:11 +0x42 one-api/relay/channel/xunfei.Handler(, , {{0xc000932230, 0x9}, {0xc001d5ad70, 0x1, 0x1}, {0x0, 0x0}, 0x0, ...}, ...) /build/relay/channel/xunfei/main.go:207 +0x4b6 one-api/relay/channel/xunfei.(Adaptor).DoResponse(0xc001e16390, 0xc001eb5500, 0x282?, 0xc001eb5900) /build/relay/channel/xunfei/adaptor.go:65 +0x1ae one-api/relay/controller.RelayTextHelper(0xc001eb5500) /build/relay/controller/text.go:172 +0xd9b one-api/controller.relay(0xc001e18065?, 0x14?) /build/controller/relay.go:39 +0x52 one-api/controller.Relay(0xc001eb5500) /build/controller/relay.go:47 +0x85 github.com/gin-gonic/gin.(Context).Next(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b one-api/router.SetRelayRouter.Distribute.func4(0xc001eb5500) /build/middleware/distributor.go:108 +0x3f4 github.com/gin-gonic/gin.(Context).Next(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b one-api/router.SetRelayRouter.TokenAuth.func3(0xc001eb5500) /build/middleware/auth.go:243 +0x946 github.com/gin-gonic/gin.(Context).Next(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b one-api/router.SetRelayRouter.RelayPanicRecover.func2(0xc001eb5598?) /build/middleware/recover.go:31 +0x45 github.com/gin-gonic/gin.(Context).Next(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b main.main.Sessions.func5(0xc001eb5500) /go/pkg/mod/github.com/gin-contrib/sessions@v0.0.5/sessions.go:54 +0x169 github.com/gin-gonic/gin.(Context).Next(...) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.LoggerWithConfig.func1(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 +0xdd github.com/gin-gonic/gin.(Context).Next(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b main.main.RequestId.func4(0xc001eb5500) /build/middleware/request-id.go:16 +0x136 github.com/gin-gonic/gin.(Context).Next(...) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x7a github.com/gin-gonic/gin.(Context).Next(...) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(Engine).handleHTTPRequest(0xc000162b60, 0xc001eb5500) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x66e github.com/gin-gonic/gin.(Engine).ServeHTTP(0xc000162b60, {0x3372590, 0xc000a57960}, 0xc000af6240) /go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1b2 net/http.serverHandler.ServeHTTP({0x336ecc8?}, {0x3372590?, 0xc000a57960?}, 0x6?) /usr/local/go/src/net/http/server.go:3137 +0x8e net/http.(conn).serve(0xc0004c14d0, {0x3374b40, 0xc00026ae10}) /usr/local/go/src/net/http/server.go:2039 +0x5e8 created by net/http.(*Server).Serve in goroutine 1 /usr/local/go/src/net/http/server.go:3285 +0x4b4

[ERR] 2024/05/27 - 20:02:43 | 20240527200242925715450k3AZufbs | request: POST /v1/chat/completions [ERR] 2024/05/27 - 20:02:43 | 20240527200242925715450k3AZufbs | request body: {"model":"SparkDesk","messages":[{"role":"user","content":"\u5f6d\u4e3d\u5a9b\u76f8\u8c8c\u8bc4\u4ef7"}]}

ai365vip commented 1 month ago

使用的哪个版本 拉取最新版本试一下呢,现在的空回复重试只针对chatgpt的流式

luomo-pro commented 1 month ago

的确我用的是非流逝请求,版本是 v0.4.3-alpha.3。 希望也能对非流逝坐下支持呢,谢谢~