From d1d789616fa24abbc1bded426466de4bfb1a72fd Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Fri, 15 Sep 2023 17:50:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=81=BF=E5=85=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=87=BA=E9=94=99=E6=97=B6=E6=9A=B4=E9=9C=B2=E6=B8=A0=E9=81=93?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++++- controller/relay-utils.go | 4 ++++ controller/relay.go | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b23f3bd2..04071649 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,15 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用 + [x] /mj/submit/change + [x] /mj/image/{id} (通过此接口获取图片,**请必须在系统设置中填写服务器地址!!**) + [x] /mj/task/{id}/fetch (此接口返回的图片地址为经过One API转发的地址) - + 使用方法:渠道类型选择自定义渠道,Base URL填写Midjourney-Proxy的地址(例如 http://localhost:8080 ),模型填入自定义模型midjourney,密钥填写Midjourney-Proxy的mj-api-secret(没有的话可以随便填)。 + + 使用方法:渠道类型选择自定义渠道 + + Base URL填写Midjourney-Proxy的地址(例如 http://localhost:8080 ) + + 模型填入自定义模型midjourney + + 密钥填写Midjourney-Proxy的mj-api-secret(没有的话可以随便填,但是不推荐)。 2. 支持在线充值功能,可在系统设置中设置,当前支持的支付接口: + [x] 易支付 +3. 支持用key查询使用额度: + + 配合项目[neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)可实现用key查询使用情况,方便二次分销 +4. 渠道显示已使用额度 ## 功能 1. 支持多种大模型: + [x] [OpenAI ChatGPT 系列模型](https://platform.openai.com/docs/guides/gpt/chat-completions-api)(支持 [Azure OpenAI API](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference)) diff --git a/controller/relay-utils.go b/controller/relay-utils.go index 9010d275..67e7e7be 100644 --- a/controller/relay-utils.go +++ b/controller/relay-utils.go @@ -106,6 +106,10 @@ func countTokenText(text string, model string) int { } func errorWrapper(err error, code string, statusCode int) *OpenAIErrorWithStatusCode { + if statusCode == http.StatusInternalServerError { + //避免暴露内部错误 + err = fmt.Errorf("internal server error") + } openAIError := OpenAIError{ Message: err.Error(), Type: "one_api_error", diff --git a/controller/relay.go b/controller/relay.go index 75be7a90..78e28e50 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -223,7 +223,7 @@ func Relay(c *gin.Context) { c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s?retry=%d", c.Request.URL.Path, retryTimes-1)) } else { if err.StatusCode == http.StatusTooManyRequests { - err.OpenAIError.Message = "当前分组上游负载已饱和,请稍后再试" + //err.OpenAIError.Message = "当前分组上游负载已饱和,请稍后再试" } c.JSON(err.StatusCode, gin.H{ "error": err.OpenAIError,