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
e7eb4474
authored
Sep 03, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add channel type FastGPT
parent
35092959
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
24 deletions
+55
-24
common/constants.go
+24
-22
web/src/constants/channel.constants.js
+1
-0
web/src/pages/Channel/EditChannel.js
+30
-2
No files found.
common/constants.go
View file @
e7eb4474
...
...
@@ -179,29 +179,31 @@ const (
ChannelType360
=
19
ChannelTypeOpenRouter
=
20
ChannelTypeAIProxyLibrary
=
21
ChannelTypeFastGPT
=
22
)
var
ChannelBaseURLs
=
[]
string
{
""
,
// 0
"https://api.openai.com"
,
// 1
"https://oa.api2d.net"
,
// 2
""
,
// 3
"https://api.closeai-proxy.xyz"
,
// 4
"https://api.openai-sb.com"
,
// 5
"https://api.openaimax.com"
,
// 6
"https://api.ohmygpt.com"
,
// 7
""
,
// 8
"https://api.caipacity.com"
,
// 9
"https://api.aiproxy.io"
,
// 10
""
,
// 11
"https://api.api2gpt.com"
,
// 12
"https://api.aigc2d.com"
,
// 13
"https://api.anthropic.com"
,
// 14
"https://aip.baidubce.com"
,
// 15
"https://open.bigmodel.cn"
,
// 16
"https://dashscope.aliyuncs.com"
,
// 17
""
,
// 18
"https://ai.360.cn"
,
// 19
"https://openrouter.ai/api"
,
// 20
"https://api.aiproxy.io"
,
// 21
""
,
// 0
"https://api.openai.com"
,
// 1
"https://oa.api2d.net"
,
// 2
""
,
// 3
"https://api.closeai-proxy.xyz"
,
// 4
"https://api.openai-sb.com"
,
// 5
"https://api.openaimax.com"
,
// 6
"https://api.ohmygpt.com"
,
// 7
""
,
// 8
"https://api.caipacity.com"
,
// 9
"https://api.aiproxy.io"
,
// 10
""
,
// 11
"https://api.api2gpt.com"
,
// 12
"https://api.aigc2d.com"
,
// 13
"https://api.anthropic.com"
,
// 14
"https://aip.baidubce.com"
,
// 15
"https://open.bigmodel.cn"
,
// 16
"https://dashscope.aliyuncs.com"
,
// 17
""
,
// 18
"https://ai.360.cn"
,
// 19
"https://openrouter.ai/api"
,
// 20
"https://api.aiproxy.io"
,
// 21
"https://fastgpt.run/api/openapi"
,
// 22
}
web/src/constants/channel.constants.js
View file @
e7eb4474
...
...
@@ -9,6 +9,7 @@ export const CHANNEL_OPTIONS = [
{
key
:
16
,
text
:
'智谱 ChatGLM'
,
value
:
16
,
color
:
'violet'
},
{
key
:
19
,
text
:
'360 智脑'
,
value
:
19
,
color
:
'blue'
},
{
key
:
8
,
text
:
'自定义渠道'
,
value
:
8
,
color
:
'pink'
},
{
key
:
22
,
text
:
'知识库:FastGPT'
,
value
:
22
,
color
:
'blue'
},
{
key
:
21
,
text
:
'知识库:AI Proxy'
,
value
:
21
,
color
:
'purple'
},
{
key
:
20
,
text
:
'代理:OpenRouter'
,
value
:
20
,
color
:
'black'
},
{
key
:
2
,
text
:
'代理:API2D'
,
value
:
2
,
color
:
'blue'
},
...
...
web/src/pages/Channel/EditChannel.js
View file @
e7eb4474
...
...
@@ -10,6 +10,20 @@ const MODEL_MAPPING_EXAMPLE = {
'gpt-4-32k-0314'
:
'gpt-4-32k'
};
function
type2secretPrompt
(
type
)
{
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
switch
(
type
)
{
case
15
:
return
"按照如下格式输入:APIKey|SecretKey"
case
18
:
return
"按照如下格式输入:APPID|APISecret|APIKey"
case
22
:
return
"按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041"
default
:
return
"请输入渠道对应的鉴权密钥"
}
}
const
EditChannel
=
()
=>
{
const
params
=
useParams
();
const
navigate
=
useNavigate
();
...
...
@@ -389,7 +403,7 @@ const EditChannel = () => {
label
=
'密钥'
name
=
'key'
required
placeholder
=
{
inputs
.
type
===
15
?
'按照如下格式输入:APIKey|SecretKey'
:
(
inputs
.
type
===
18
?
'按照如下格式输入:APPID|APISecret|APIKey'
:
'请输入渠道对应的鉴权密钥'
)}
placeholder
=
{
type2secretPrompt
(
inputs
.
type
)}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
key
}
autoComplete
=
'new-password'
...
...
@@ -407,7 +421,7 @@ const EditChannel = () => {
)
}
{
inputs
.
type
!==
3
&&
inputs
.
type
!==
8
&&
(
inputs
.
type
!==
3
&&
inputs
.
type
!==
8
&&
inputs
.
type
!==
22
&&
(
<
Form
.
Field
>
<
Form
.
Input
label
=
'代理'
...
...
@@ -420,6 +434,20 @@ const EditChannel = () => {
<
/Form.Field
>
)
}
{
inputs
.
type
===
22
&&
(
<
Form
.
Field
>
<
Form
.
Input
label
=
'私有部署地址'
name
=
'base_url'
placeholder
=
{
'请输入私有部署地址,格式为:https://fastgpt.run/api/openapi'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
base_url
}
autoComplete
=
'new-password'
/>
<
/Form.Field
>
)
}
<
Button
onClick
=
{
handleCancel
}
>
取消
<
/Button
>
<
Button
type
=
{
isEdit
?
'button'
:
'submit'
}
positive
onClick
=
{
submit
}
>
提交
<
/Button
>
<
/Form
>
...
...
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