From 81167c4322e0c142348906a6b39ea5651ed6185b Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Thu, 22 Feb 2024 19:42:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=B0=E5=BD=95=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/relay.go | 7 ++++--- middleware/distributor.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controller/relay.go b/controller/relay.go index c7cd4b5..9188b01 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -409,12 +409,13 @@ func RelayMidjourney(c *gin.Context) { if err.Code == 30 { err.Result = "当前分组负载已饱和,请稍后再试,或升级账户以提升服务质量。" } - c.JSON(400, gin.H{ - "error": err.Description + " " + err.Result, + c.JSON(429, gin.H{ + "error": fmt.Sprintf("%s %s", err.Description, err.Result), + "type": "upstream_error", }) } channelId := c.GetInt("channel_id") - common.SysError(fmt.Sprintf("relay error (channel #%d): %s", channelId, err.Result)) + common.SysError(fmt.Sprintf("relay error (channel #%d): %s", channelId, fmt.Sprintf("%s %s", err.Description, err.Result))) //if shouldDisableChannel(&err.OpenAIError) { // channelId := c.GetInt("channel_id") // channelName := c.GetString("channel_name") diff --git a/middleware/distributor.go b/middleware/distributor.go index 51945a4..e105fb8 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -48,7 +48,7 @@ func Distribute() func(c *gin.Context) { err = common.UnmarshalBodyReusable(c, &modelRequest) } if err != nil { - abortWithMessage(c, http.StatusBadRequest, "无效的请求: "+err.Error()) + abortWithMessage(c, http.StatusBadRequest, "无效的请求, "+err.Error()) return } if strings.HasPrefix(c.Request.URL.Path, "/v1/moderations") {