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
c4f664f3
authored
Jun 08, 2025
by
RedwindA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
馃帹
feat(channel): add endpoint to retrieve models by tag
parent
b6dd9f96
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
controller/channel.go
+41
-0
router/api-router.go
+1
-0
No files found.
controller/channel.go
View file @
c4f664f3
...
...
@@ -623,3 +623,44 @@ func BatchSetChannelTag(c *gin.Context) {
})
return
}
func
GetTagModels
(
c
*
gin
.
Context
)
{
tag
:=
c
.
Query
(
"tag"
)
if
tag
==
""
{
c
.
JSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"success"
:
false
,
"message"
:
"tag涓嶈兘涓虹┖"
,
})
return
}
channels
,
err
:=
model
.
GetChannelsByTag
(
tag
,
false
)
// Assuming false for idSort is fine here
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
var
longestModels
string
maxLength
:=
0
// Find the longest models string among all channels with the given tag
for
_
,
channel
:=
range
channels
{
if
channel
.
Models
!=
""
{
currentModels
:=
strings
.
Split
(
channel
.
Models
,
","
)
if
len
(
currentModels
)
>
maxLength
{
maxLength
=
len
(
currentModels
)
longestModels
=
channel
.
Models
}
}
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"message"
:
""
,
"data"
:
longestModels
,
})
return
}
router/api-router.go
View file @
c4f664f3
...
...
@@ -105,6 +105,7 @@ func SetApiRouter(router *gin.Engine) {
channelRoute
.
GET
(
"/fetch_models/:id"
,
controller
.
FetchUpstreamModels
)
channelRoute
.
POST
(
"/fetch_models"
,
controller
.
FetchModels
)
channelRoute
.
POST
(
"/batch/tag"
,
controller
.
BatchSetChannelTag
)
channelRoute
.
GET
(
"/tag/models"
,
controller
.
GetTagModels
)
}
tokenRoute
:=
apiRouter
.
Group
(
"/token"
)
tokenRoute
.
Use
(
middleware
.
UserAuth
())
...
...
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