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
a8667261
authored
Feb 29, 2024
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: "/v1/models" 只返回用户可用模型 (close #78)
parent
6ada7b87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletions
+19
-1
controller/model.go
+19
-1
No files found.
controller/model.go
View file @
a8667261
...
...
@@ -3,7 +3,9 @@ package controller
import
(
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"one-api/dto"
"one-api/model"
"one-api/relay"
"one-api/relay/channel/ai360"
"one-api/relay/channel/moonshot"
...
...
@@ -105,9 +107,25 @@ func init() {
}
func
ListModels
(
c
*
gin
.
Context
)
{
userId
:=
c
.
GetInt
(
"id"
)
user
,
err
:=
model
.
GetUserById
(
userId
,
true
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
models
:=
model
.
GetGroupModels
(
user
.
Group
)
userOpenAiModels
:=
make
([]
OpenAIModels
,
0
)
for
_
,
s
:=
range
models
{
if
_
,
ok
:=
openAIModelsMap
[
s
];
ok
{
userOpenAiModels
=
append
(
userOpenAiModels
,
openAIModelsMap
[
s
])
}
}
c
.
JSON
(
200
,
gin
.
H
{
"object"
:
"list"
,
"data"
:
openAI
Models
,
"data"
:
userOpenAi
Models
,
})
}
...
...
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