MartialBE / one-hub

OpenAI 接口管理 & 分发系统,改自songquanpeng/one-api。支持更多模型,加入统计页面,完善非openai模型的函数调用。
https://one-api-martialbe.vercel.app/
Apache License 2.0
996 stars 197 forks source link

请求 embedding 时出现 panic detected: runtime error #303

Closed GrayXu closed 1 month ago

GrayXu commented 1 month ago

例行检查

问题描述

请求embedding接口时出现panic detected: runtime error。 前端是fastgpt,后端接入的embedding model是BAAI/bge-large-en-v1.5

[GIN] 2024/07/17 - 17:12:39 | 20240717171239451986572z2v4vbed | 500 |   74.937267ms | XXXXXXXXX |    POST /v1/embeddings
[SYS] 2024/07/17 - 17:12:39 | panic detected: runtime error: invalid memory address or nil pointer dereference
[SYS] 2024/07/17 - 17:12:39 | stacktrace from panic: goroutine 108322 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.22.5/x64/src/runtime/debug/stack.go:24 +0x5e
one-api/router.setOpenAIRouter.RelayPanicRecover.func3.1()
        /home/runner/work/one-hub/one-hub/middleware/recover.go:17 +0x70
panic({0x1598b80?, 0x3199aa0?})
        /opt/hostedtoolcache/go/1.22.5/x64/src/runtime/panic.go:770 +0x132
one-api/providers/openai.(*OpenAIProvider).CreateEmbeddings(0xc004d2d700, 0xc002c0d348?)
        /home/runner/work/one-hub/one-hub/providers/openai/embeddings.go:32 +0x1be
one-api/relay.(*relayEmbeddings).send(0xc004ea93b0)
        /home/runner/work/one-hub/one-hub/relay/embeddings.go:52 +0x7b
one-api/relay.RelayHandler({0x272f320, 0xc004ea93b0})
        /home/runner/work/one-hub/one-hub/relay/main.go:108 +0xee
one-api/relay.Relay(0xc0000d3b00)
        /home/runner/work/one-hub/one-hub/relay/main.go:46 +0x13b
github.com/gin-gonic/gin.(*Context).Next(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
one-api/router.setOpenAIRouter.Distribute.func5(0xc0000d3b00)
        /home/runner/work/one-hub/one-hub/middleware/distributor.go:14 +0x59
github.com/gin-gonic/gin.(*Context).Next(...)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
one-api/middleware.tokenAuth(0xc0000d3b00, {0xc004e90c00?, 0x3a?})
        /home/runner/work/one-hub/one-hub/middleware/auth.go:131 +0x422
one-api/router.setOpenAIRouter.OpenaiAuth.func4(0xc0000d3b00)
        /home/runner/work/one-hub/one-hub/middleware/auth.go:137 +0x3f
github.com/gin-gonic/gin.(*Context).Next(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
one-api/router.setOpenAIRouter.RelayPanicRecover.func3(0xc0000d3b98?)
        /home/runner/work/one-hub/one-hub/middleware/recover.go:27 +0x45
github.com/gin-gonic/gin.(*Context).Next(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
main.initHttpServer.Sessions.func2(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-contrib/sessions@v0.0.4/sessions.go:54 +0x169
github.com/gin-gonic/gin.(*Context).Next(...)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.LoggerWithConfig.func1(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 +0xdd
github.com/gin-gonic/gin.(*Context).Next(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 +0x2b
main.initHttpServer.RequestId.func1(0xc0000d3b00)
        /home/runner/work/one-hub/one-hub/middleware/request-id.go:20 +0x1a7
github.com/gin-gonic/gin.(*Context).Next(...)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x7a
github.com/gin-gonic/gin.(*Context).Next(...)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc0000f01a0, 0xc0000d3b00)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x66e
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc0000f01a0, {0x271e988, 0xc004a67dc0}, 0xc004eafe60)
        /home/runner/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1b2
net/http.serverHandler.ServeHTTP({0x271a408?}, {0x271e988?, 0xc004a67dc0?}, 0x6?)
        /opt/hostedtoolcache/go/1.22.5/x64/src/net/http/server.go:3142 +0x8e
net/http.(*conn).serve(0xc004ea9170, {0x2721ca0, 0xc0006c82d0})
        /opt/hostedtoolcache/go/1.22.5/x64/src/net/http/server.go:2044 +0x5e8
created by net/http.(*Server).Serve in goroutine 1
        /opt/hostedtoolcache/go/1.22.5/x64/src/net/http/server.go:3290 +0x4b4
MartialBE commented 1 month ago

已修复