Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
76c0c791
authored
Sep 15, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 避免请求出错时暴露渠道信息
parent
3b780e33
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
README.md
+7
-1
controller/relay-utils.go
+4
-0
controller/relay.go
+1
-1
No files found.
README.md
View file @
76c0c791
...
@@ -64,9 +64,15 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
...
@@ -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
)
)
...
...
controller/relay-utils.go
View file @
76c0c791
...
@@ -106,6 +106,10 @@ func countTokenText(text string, model string) int {
...
@@ -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"
,
...
...
controller/relay.go
View file @
76c0c791
...
@@ -223,7 +223,7 @@ func Relay(c *gin.Context) {
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment