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
8a1d1695
authored
Dec 04, 2024
by
iszcz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
89631463
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
relay/channel/openai/adaptor.go
+9
-5
service/quota.go
+1
-1
No files found.
relay/channel/openai/adaptor.go
View file @
8a1d1695
...
...
@@ -32,11 +32,15 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
if
info
.
RelayMode
==
constant
.
RelayModeRealtime
{
// trim https
baseUrl
:=
strings
.
TrimPrefix
(
info
.
BaseUrl
,
"https://"
)
baseUrl
=
strings
.
TrimPrefix
(
baseUrl
,
"http://"
)
baseUrl
=
"wss://"
+
baseUrl
info
.
BaseUrl
=
baseUrl
if
strings
.
HasPrefix
(
info
.
BaseUrl
,
"https://"
)
{
baseUrl
:=
strings
.
TrimPrefix
(
info
.
BaseUrl
,
"https://"
)
baseUrl
=
"wss://"
+
baseUrl
info
.
BaseUrl
=
baseUrl
}
else
if
strings
.
HasPrefix
(
info
.
BaseUrl
,
"http://"
)
{
baseUrl
:=
strings
.
TrimPrefix
(
info
.
BaseUrl
,
"http://"
)
baseUrl
=
"ws://"
+
baseUrl
info
.
BaseUrl
=
baseUrl
}
}
switch
info
.
ChannelType
{
case
common
.
ChannelTypeAzure
:
...
...
service/quota.go
View file @
8a1d1695
...
...
@@ -53,7 +53,7 @@ func PreWssConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usag
return
errors
.
New
(
fmt
.
Sprintf
(
"用户额度不足,剩余额度为 %d"
,
userQuota
))
}
if
token
.
RemainQuota
<
quota
{
if
!
token
.
UnlimitedQuota
&&
token
.
RemainQuota
<
quota
{
return
errors
.
New
(
fmt
.
Sprintf
(
"令牌额度不足,剩余额度为 %d"
,
token
.
RemainQuota
))
}
...
...
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