Files
ai-agent/internal/handlers/dashboard/platform_ai_handler.go
T

35 lines
872 B
Go
Raw Normal View History

package dashboard
import (
"code.tczkiot.com/wlw/ai-agent/internal/pkg/constants"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/httpx"
"code.tczkiot.com/wlw/ai-agent/internal/services"
"github.com/gin-gonic/gin"
)
func PlatformAIGetStatus(ctx *gin.Context) {
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionAIAgentView); err != nil {
httpx.WriteJSON(ctx, err)
return
}
source, err := services.PlatformAIService.ModelSource(ctx.Request.Context())
if err != nil {
httpx.WriteJSON(ctx, err)
return
}
if source != "platform" {
httpx.WriteJSON(ctx, map[string]any{"model_source": source})
return
}
status, err := services.PlatformAIService.Status(ctx.Request.Context())
if err != nil {
httpx.WriteJSON(ctx, err)
return
}
httpx.WriteJSON(ctx, map[string]any{
"model_source": source,
"status": status,
})
}