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
c32aa170
authored
Jun 20, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support custom base url for channels
parent
cab830b7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
controller/channel-test.go
+1
-3
controller/relay-text.go
+0
-4
web/src/pages/Channel/EditChannel.js
+14
-0
No files found.
controller/channel-test.go
View file @
c32aa170
...
...
@@ -25,9 +25,7 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
if
channel
.
Type
==
common
.
ChannelTypeAzure
{
requestURL
=
fmt
.
Sprintf
(
"%s/openai/deployments/%s/chat/completions?api-version=2023-03-15-preview"
,
channel
.
BaseURL
,
request
.
Model
)
}
else
{
if
channel
.
Type
==
common
.
ChannelTypeCustom
{
requestURL
=
channel
.
BaseURL
}
else
if
channel
.
Type
==
common
.
ChannelTypeOpenAI
&&
channel
.
BaseURL
!=
""
{
if
channel
.
BaseURL
!=
""
{
requestURL
=
channel
.
BaseURL
}
requestURL
+=
"/v1/chat/completions"
...
...
controller/relay-text.go
View file @
c32aa170
...
...
@@ -30,13 +30,9 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
}
baseURL
:=
common
.
ChannelBaseURLs
[
channelType
]
requestURL
:=
c
.
Request
.
URL
.
String
()
if
channelType
==
common
.
ChannelTypeCustom
{
baseURL
=
c
.
GetString
(
"base_url"
)
}
else
if
channelType
==
common
.
ChannelTypeOpenAI
{
if
c
.
GetString
(
"base_url"
)
!=
""
{
baseURL
=
c
.
GetString
(
"base_url"
)
}
}
fullRequestURL
:=
fmt
.
Sprintf
(
"%s%s"
,
baseURL
,
requestURL
)
if
channelType
==
common
.
ChannelTypeAzure
{
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
...
...
web/src/pages/Channel/EditChannel.js
View file @
c32aa170
...
...
@@ -177,6 +177,20 @@ const EditChannel = () => {
<
/Form.Field
>
)
}
{
inputs
.
type
!==
3
&&
inputs
.
type
!==
8
&&
(
<
Form
.
Field
>
<
Form
.
Input
label
=
'Base URL'
name
=
'base_url'
placeholder
=
{
'请输入自定义 Base URL,格式为:https://domain.com,可不填,不填使用渠道默认值'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
base_url
}
autoComplete
=
'new-password'
/>
<
/Form.Field
>
)
}
<
Form
.
Field
>
<
Form
.
Input
label
=
'名称'
...
...
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