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
411bbac0
authored
Sep 26, 2024
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Playground相关接口禁用AccessToken
parent
b22d5fde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
controller/relay.go
+6
-2
middleware/auth.go
+1
-0
No files found.
controller/relay.go
View file @
411bbac0
...
...
@@ -49,6 +49,12 @@ func Playground(c *gin.Context) {
}
}()
useAccessToken
:=
c
.
GetBool
(
"use_access_token"
)
if
useAccessToken
{
openaiErr
=
service
.
OpenAIErrorWrapperLocal
(
errors
.
New
(
"暂不支持使用 access token"
),
"access_token_not_supported"
,
http
.
StatusBadRequest
)
return
}
playgroundRequest
:=
&
dto
.
PlayGroundRequest
{}
err
:=
common
.
UnmarshalBodyReusable
(
c
,
playgroundRequest
)
if
err
!=
nil
{
...
...
@@ -67,8 +73,6 @@ func Playground(c *gin.Context) {
}
else
{
c
.
Set
(
"group"
,
group
)
}
log
.
Printf
(
"group: %s"
,
group
)
log
.
Printf
(
"model: %s"
,
playgroundRequest
.
Model
)
channel
,
err
:=
model
.
CacheGetRandomSatisfiedChannel
(
group
,
playgroundRequest
.
Model
,
0
)
if
err
!=
nil
{
openaiErr
=
service
.
OpenAIErrorWrapperLocal
(
err
,
"get_playground_channel_failed"
,
http
.
StatusInternalServerError
)
...
...
middleware/auth.go
View file @
411bbac0
...
...
@@ -122,6 +122,7 @@ func authHelper(c *gin.Context, minRole int) {
c
.
Set
(
"role"
,
role
)
c
.
Set
(
"id"
,
id
)
c
.
Set
(
"group"
,
session
.
Get
(
"group"
))
c
.
Set
(
"use_access_token"
,
useAccessToken
)
c
.
Next
()
}
...
...
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