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
3ada9185
authored
Jul 17, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: distribute panic
parent
9e592b56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletions
+6
-1
middleware/distributor.go
+6
-1
No files found.
middleware/distributor.go
View file @
3ada9185
package
middleware
import
(
"errors"
"fmt"
"net/http"
"one-api/common"
...
...
@@ -25,6 +26,10 @@ func Distribute() func(c *gin.Context) {
var
channel
*
model
.
Channel
channelId
,
ok
:=
c
.
Get
(
"specific_channel_id"
)
modelRequest
,
shouldSelectChannel
,
err
:=
getModelRequest
(
c
)
if
err
!=
nil
{
abortWithOpenAiMessage
(
c
,
http
.
StatusBadRequest
,
"Invalid request, "
+
err
.
Error
())
return
}
userGroup
,
_
:=
model
.
CacheGetUserGroup
(
userId
)
c
.
Set
(
"group"
,
userGroup
)
if
ok
{
...
...
@@ -141,7 +146,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
}
if
err
!=
nil
{
abortWithOpenAiMessage
(
c
,
http
.
StatusBadRequest
,
"无效的请求, "
+
err
.
Error
())
return
nil
,
false
,
err
return
nil
,
false
,
err
ors
.
New
(
"无效的请求, "
+
err
.
Error
())
}
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/moderations"
)
{
if
modelRequest
.
Model
==
""
{
...
...
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