feat: 避免请求出错时暴露渠道信息
This commit is contained in:
parent
d9deda18c1
commit
d1d789616f
@ -64,9 +64,15 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
|
|||||||
+ [x] /mj/submit/change
|
+ [x] /mj/submit/change
|
||||||
+ [x] /mj/image/{id} (通过此接口获取图片,**请必须在系统设置中填写服务器地址!!**)
|
+ [x] /mj/image/{id} (通过此接口获取图片,**请必须在系统设置中填写服务器地址!!**)
|
||||||
+ [x] /mj/task/{id}/fetch (此接口返回的图片地址为经过One API转发的地址)
|
+ [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. 支持在线充值功能,可在系统设置中设置,当前支持的支付接口:
|
2. 支持在线充值功能,可在系统设置中设置,当前支持的支付接口:
|
||||||
+ [x] 易支付
|
+ [x] 易支付
|
||||||
|
3. 支持用key查询使用额度:
|
||||||
|
+ 配合项目[neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)可实现用key查询使用情况,方便二次分销
|
||||||
|
4. 渠道显示已使用额度
|
||||||
## 功能
|
## 功能
|
||||||
1. 支持多种大模型:
|
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))
|
+ [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))
|
||||||
|
@ -106,6 +106,10 @@ func countTokenText(text string, model string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func errorWrapper(err error, code string, statusCode int) *OpenAIErrorWithStatusCode {
|
func errorWrapper(err error, code string, statusCode int) *OpenAIErrorWithStatusCode {
|
||||||
|
if statusCode == http.StatusInternalServerError {
|
||||||
|
//避免暴露内部错误
|
||||||
|
err = fmt.Errorf("internal server error")
|
||||||
|
}
|
||||||
openAIError := OpenAIError{
|
openAIError := OpenAIError{
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
Type: "one_api_error",
|
Type: "one_api_error",
|
||||||
|
@ -223,7 +223,7 @@ func Relay(c *gin.Context) {
|
|||||||
c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s?retry=%d", c.Request.URL.Path, retryTimes-1))
|
c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s?retry=%d", c.Request.URL.Path, retryTimes-1))
|
||||||
} else {
|
} else {
|
||||||
if err.StatusCode == http.StatusTooManyRequests {
|
if err.StatusCode == http.StatusTooManyRequests {
|
||||||
err.OpenAIError.Message = "当前分组上游负载已饱和,请稍后再试"
|
//err.OpenAIError.Message = "当前分组上游负载已饱和,请稍后再试"
|
||||||
}
|
}
|
||||||
c.JSON(err.StatusCode, gin.H{
|
c.JSON(err.StatusCode, gin.H{
|
||||||
"error": err.OpenAIError,
|
"error": err.OpenAIError,
|
||||||
|
Loading…
Reference in New Issue
Block a user