fix: channel listing
This commit is contained in:
parent
657de89219
commit
082dd33ffa
@ -332,22 +332,24 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListModels(c *gin.Context) {
|
func ListModels(c *gin.Context, isChannel bool) {
|
||||||
userId := c.GetInt("id")
|
userId := c.GetInt("id")
|
||||||
userGroup, _ := model.CacheGetUserGroup(userId)
|
userGroup, _ := model.CacheGetUserGroup(userId)
|
||||||
|
|
||||||
// Only return the models that the channel and user have access to
|
// Only return the models that the channel and user have access to
|
||||||
var modalList []OpenAIModels
|
var modalList []OpenAIModels
|
||||||
|
|
||||||
for _, modalData := range openAIModels {
|
if !isChannel {
|
||||||
channel, err := model.CacheGetRandomSatisfiedChannel(userGroup, modalData.Id)
|
for _, modalData := range openAIModels {
|
||||||
|
channel, err := model.CacheGetRandomSatisfiedChannel(userGroup, modalData.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel != nil {
|
if channel != nil {
|
||||||
modalList = append(modalList, modalData)
|
modalList = append(modalList, modalData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,9 @@ func SetApiRouter(router *gin.Engine) {
|
|||||||
{
|
{
|
||||||
channelRoute.GET("/", controller.GetAllChannels)
|
channelRoute.GET("/", controller.GetAllChannels)
|
||||||
channelRoute.GET("/search", controller.SearchChannels)
|
channelRoute.GET("/search", controller.SearchChannels)
|
||||||
channelRoute.GET("/models", controller.ListModels)
|
channelRoute.GET("/models", func(c *gin.Context) {
|
||||||
|
controller.ListModels(c, true)
|
||||||
|
})
|
||||||
channelRoute.GET("/:id", controller.GetChannel)
|
channelRoute.GET("/:id", controller.GetChannel)
|
||||||
channelRoute.GET("/test", controller.TestAllChannels)
|
channelRoute.GET("/test", controller.TestAllChannels)
|
||||||
channelRoute.GET("/test/:id", controller.TestChannel)
|
channelRoute.GET("/test/:id", controller.TestChannel)
|
||||||
|
@ -12,7 +12,9 @@ func SetRelayRouter(router *gin.Engine) {
|
|||||||
modelsRouter := router.Group("/v1/models")
|
modelsRouter := router.Group("/v1/models")
|
||||||
modelsRouter.Use(middleware.TokenAuth())
|
modelsRouter.Use(middleware.TokenAuth())
|
||||||
{
|
{
|
||||||
modelsRouter.GET("/", controller.ListModels)
|
modelsRouter.GET("/", func(c *gin.Context) {
|
||||||
|
controller.ListModels(c, false)
|
||||||
|
})
|
||||||
modelsRouter.GET("/:model", controller.RetrieveModel)
|
modelsRouter.GET("/:model", controller.RetrieveModel)
|
||||||
}
|
}
|
||||||
relayV1Router := router.Group("/v1")
|
relayV1Router := router.Group("/v1")
|
||||||
|
Loading…
Reference in New Issue
Block a user