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
30b8bb36
authored
Oct 14, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support cloudflare AI gateway now (close #565, #598)
parent
2a99fae1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
README.md
+5
-4
controller/relay-text.go
+5
-0
No files found.
README.md
View file @
30b8bb36
...
@@ -95,12 +95,13 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
...
@@ -95,12 +95,13 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
15.
支持模型映射,重定向用户的请求模型。
15.
支持模型映射,重定向用户的请求模型。
16.
支持失败自动重试。
16.
支持失败自动重试。
17.
支持绘图接口。
17.
支持绘图接口。
18.
支持丰富的
**自定义**
设置,
18.
支持
[
Cloudflare AI Gateway
](
https://developers.cloudflare.com/ai-gateway/providers/openai/
)
,渠道设置的代理部分填写
`https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/openai`
即可。
19.
支持丰富的
**自定义**
设置,
1.
支持自定义系统名称,logo 以及页脚。
1.
支持自定义系统名称,logo 以及页脚。
2.
支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
2.
支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
19
.
支持通过系统访问令牌访问管理 API。
20
.
支持通过系统访问令牌访问管理 API。
2
0
.
支持 Cloudflare Turnstile 用户校验。
2
1
.
支持 Cloudflare Turnstile 用户校验。
2
1
.
支持用户管理,支持
**多种用户登录注册方式**
:
2
2
.
支持用户管理,支持
**多种用户登录注册方式**
:
+
邮箱登录注册(支持注册邮箱白名单)以及通过邮箱进行密码重置。
+
邮箱登录注册(支持注册邮箱白名单)以及通过邮箱进行密码重置。
+
[
GitHub 开放授权
](
https://github.com/settings/applications/new
)
。
+
[
GitHub 开放授权
](
https://github.com/settings/applications/new
)
。
+
微信公众号授权(需要额外部署
[
WeChat Server
](
https://github.com/songquanpeng/wechat-server
)
)。
+
微信公众号授权(需要额外部署
[
WeChat Server
](
https://github.com/songquanpeng/wechat-server
)
)。
...
...
controller/relay-text.go
View file @
30b8bb36
...
@@ -119,6 +119,11 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
...
@@ -119,6 +119,11 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
baseURL
=
c
.
GetString
(
"base_url"
)
baseURL
=
c
.
GetString
(
"base_url"
)
}
}
fullRequestURL
:=
fmt
.
Sprintf
(
"%s%s"
,
baseURL
,
requestURL
)
fullRequestURL
:=
fmt
.
Sprintf
(
"%s%s"
,
baseURL
,
requestURL
)
if
channelType
==
common
.
ChannelTypeOpenAI
{
if
strings
.
HasPrefix
(
baseURL
,
"https://gateway.ai.cloudflare.com"
)
{
fullRequestURL
=
fmt
.
Sprintf
(
"%s%s"
,
baseURL
,
strings
.
TrimPrefix
(
requestURL
,
"/v1"
))
}
}
switch
apiType
{
switch
apiType
{
case
APITypeOpenAI
:
case
APITypeOpenAI
:
if
channelType
==
common
.
ChannelTypeAzure
{
if
channelType
==
common
.
ChannelTypeAzure
{
...
...
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