mirror of
https://github.com/labring/sealos.git
synced 2026-09-21 05:44:43 +08:00
* feat: get balance notify * feat: balance notify * feat: auto test bannel channel notify * feat: notify lock limit * feat: notify throttle * fix: claude think token * feat: azure support and mode string * feat: feishu notify * fix: banned notify * fix: lint * feat: notify note * feat: notify note * fix: do not expire banned * fix: default disable auto update channel balance * feat: beyond threshold notify * feat: notify error detial * fix: add request script * feat: sync service error notify * feat: baidu error code handler * feat: baidu error code handler * fix: unsupported mode info * refactor: relay error handler * feat: auto reload channel and model config * feat: ollama support * fix: lint * chore: error log message * chore: sync notify throttle * fix: redis script key expire * feat: no permission channel notify * feat: get channel with error rate priority * feat: retry log filed * fix: lint * fix: group and token update sql double where id condition * feat: async batch process usage * fix: rate limit overlimit count * fix: rate limit count * fix: no permission error message * fix: ban expiry * feat: mem model monitor * feat: mem monitor cleanup * feat: guess model type cache * fix: get priority * fix: do not unban when error rate reduce * chore: docker image add curl cli * fix: model not exist status code * fix: error code * fix: record consume notify and clean log batch size * chore: batch record * fix: clean log error notify throttle * chore: rename notify env name
93 lines
2.4 KiB
Go
93 lines
2.4 KiB
Go
package controller
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/labring/sealos/service/aiproxy/middleware"
|
|
"github.com/labring/sealos/service/aiproxy/monitor"
|
|
)
|
|
|
|
func GetAllChannelModelErrorRates(c *gin.Context) {
|
|
rates, err := monitor.GetAllChannelModelErrorRates(c.Request.Context())
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, rates)
|
|
}
|
|
|
|
func GetChannelModelErrorRates(c *gin.Context) {
|
|
channelID := c.Param("id")
|
|
channelIDInt, err := strconv.ParseInt(channelID, 10, 64)
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, "Invalid channel ID")
|
|
return
|
|
}
|
|
rates, err := monitor.GetChannelModelErrorRates(c.Request.Context(), channelIDInt)
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, rates)
|
|
}
|
|
|
|
func ClearAllModelErrors(c *gin.Context) {
|
|
err := monitor.ClearAllModelErrors(c.Request.Context())
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.Status(http.StatusNoContent)
|
|
}
|
|
|
|
func ClearChannelAllModelErrors(c *gin.Context) {
|
|
channelID := c.Param("id")
|
|
channelIDInt, err := strconv.ParseInt(channelID, 10, 64)
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, "Invalid channel ID")
|
|
return
|
|
}
|
|
err = monitor.ClearChannelAllModelErrors(c.Request.Context(), int(channelIDInt))
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.Status(http.StatusNoContent)
|
|
}
|
|
|
|
func ClearChannelModelErrors(c *gin.Context) {
|
|
channelID := c.Param("id")
|
|
model := c.Param("model")
|
|
channelIDInt, err := strconv.ParseInt(channelID, 10, 64)
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, "Invalid channel ID")
|
|
return
|
|
}
|
|
err = monitor.ClearChannelModelErrors(c.Request.Context(), model, int(channelIDInt))
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.Status(http.StatusNoContent)
|
|
}
|
|
|
|
func GetModelsErrorRate(c *gin.Context) {
|
|
rates, err := monitor.GetModelsErrorRate(c.Request.Context())
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, rates)
|
|
}
|
|
|
|
func GetAllBannedModelChannels(c *gin.Context) {
|
|
channels, err := monitor.GetAllBannedModelChannels(c.Request.Context())
|
|
if err != nil {
|
|
middleware.ErrorResponse(c, http.StatusOK, err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, channels)
|
|
}
|