mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-27 08:00:32 +00:00
* feat(ai): add GPU environment diagnostics and device summaries * chore(ai): remove GPU diagnostics comments and test files * feat: separate host and container GPU environment status * fix(ai): correct GPU environment diagnostics and timeout handling --------- Co-authored-by: ssongliu <sloooop1x@gmail.com>
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package v2
|
|
|
|
import (
|
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
|
"github.com/1Panel-dev/1Panel/agent/app/service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (b *BaseApi) LoadModelGPUDevices(c *gin.Context) {
|
|
helper.SuccessWithData(c, service.LoadModelGPUDevices())
|
|
}
|
|
|
|
// @Tags AI
|
|
// @Summary Load gpu / xpu info
|
|
// @Accept json
|
|
// @Success 200
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /ai/gpu/load [get]
|
|
func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
|
|
info, err := service.LoadGPUInfo(c.Request.Context(), c.Query("refresh") == "true")
|
|
if err != nil {
|
|
helper.BadRequest(c, err)
|
|
return
|
|
}
|
|
helper.SuccessWithData(c, info)
|
|
}
|
|
|
|
// @Tags AI
|
|
// @Summary Get CPU options
|
|
// @Success 200
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /ai/gpu/options [get]
|
|
func (b *BaseApi) GetCPUOptions(c *gin.Context) {
|
|
helper.SuccessWithData(c, monitorService.LoadGPUOptions())
|
|
}
|
|
|
|
// @Tags Monitor
|
|
// @Summary Load monitor data
|
|
// @Param request body dto.MonitorGPUSearch true "request"
|
|
// @Success 200 {object} dto.MonitorGPUData
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /ai/gpu/search [post]
|
|
func (b *BaseApi) LoadGPUMonitor(c *gin.Context) {
|
|
var req dto.MonitorGPUSearch
|
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
return
|
|
}
|
|
|
|
data, err := monitorService.LoadGPUMonitorData(req)
|
|
if err != nil {
|
|
helper.InternalServer(c, err)
|
|
return
|
|
}
|
|
helper.SuccessWithData(c, data)
|
|
}
|