api

package
v0.0.0-681bd29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircuitBreakerInfo

type CircuitBreakerInfo struct {
	ID           string `json:"id"`
	Type         string `json:"type"`          // "endpoint" 或 "service"
	Name         string `json:"name"`          // 显示名称
	ModelID      string `json:"model_id"`      // 关联模型 ID
	ModelName    string `json:"model_name"`    // 关联模型名称
	ProviderID   string `json:"provider_id"`   // 关联供应商 ID
	ProviderName string `json:"provider_name"` // 关联供应商名称
	URL          string `json:"url"`           // 关联的 URL 地址
}

type Dashboard

type Dashboard struct {
	DB          *gorm.DB
	RedisClient *redis.Client
	RedisSync   *biz.ConfigRedisSync
	// contains filtered or unexported fields
}

func (*Dashboard) HandleWebSocket

func (a *Dashboard) HandleWebSocket(c *gin.Context)

HandleWebSocket upgrades the HTTP request to WebSocket and pushes dashboard metrics

func (*Dashboard) IsPrometheusAvailable

func (a *Dashboard) IsPrometheusAvailable() bool

IsPrometheusAvailable 导出的版本,用于测试

func (*Dashboard) QueryCircuitBreakers

func (a *Dashboard) QueryCircuitBreakers(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary Query all endpoints that are currently in Open/Isolated state from Redis @Success 200 {object} util.ResponseResult{data=[]CircuitBreakerInfo} @Router /api/v1/dashboard/circuit-breakers [get]

func (*Dashboard) QueryModelRanking

func (a *Dashboard) QueryModelRanking(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary Query model usage ranking with detailed metrics @Param sort_by query string false "Sort by: request_count, avg_latency, avg_ttft, tokens, cost, success_rate (default: request_count)" @Param limit query int false "Limit results (default: 10)" @Success 200 {object} util.ResponseResult{data=[]ModelRankingItem} @Router /api/v1/dashboard/model-ranking [get]

func (*Dashboard) QueryOverview

func (a *Dashboard) QueryOverview(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary Query dashboard overview metrics (QPS, daily stats, latency, circuit breakers) @Success 200 {object} util.ResponseResult{data=OverviewResponse} @Router /api/v1/dashboard/overview [get]

func (*Dashboard) QueryQPS

func (a *Dashboard) QueryQPS(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary Query real-time gateway QPS from Prometheus @Success 200 {object} util.ResponseResult{data=float64} @Router /api/v1/dashboard/qps [get]

func (*Dashboard) QueryTrends

func (a *Dashboard) QueryTrends(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary Query bucketed gateway traffic success/failure trends @Param group_by query string false "Group by: model, provider, tenant, endpoint (default: global)" @Param time_range query string false "Time range: 1h, 6h, 24h, 7d, today (default: 1h)" @Success 200 {object} util.ResponseResult{data=TrendsResponse} @Router /api/v1/dashboard/trends [get]

func (*Dashboard) SyncRedis

func (a *Dashboard) SyncRedis(c *gin.Context)

@Tags DashboardAPI @Security ApiKeyAuth @Summary One-click synchronization of database configuration to Redis @Success 200 {object} util.ResponseResult @Router /api/v1/dashboard/sync-redis [post]

type ModelRankingItem

type ModelRankingItem struct {
	ModelID      string  `json:"model_id"`
	ModelCode    string  `json:"model_code"`
	ModelName    string  `json:"model_name"`
	RequestCount int64   `json:"request_count"`
	SuccessCount int64   `json:"success_count"`
	FailCount    int64   `json:"fail_count"`
	SuccessRate  float64 `json:"success_rate"`
	AvgLatencyMs float64 `json:"avg_latency_ms"`
	P50LatencyMs float64 `json:"p50_latency_ms"`
	P95LatencyMs float64 `json:"p95_latency_ms"`
	P99LatencyMs float64 `json:"p99_latency_ms"`
	AvgTTFTMs    float64 `json:"avg_ttft_ms"`
	P50TTFTMs    float64 `json:"p50_ttft_ms"`
	P95TTFTMs    float64 `json:"p95_ttft_ms"`
	P99TTFTMs    float64 `json:"p99_ttft_ms"`
	TotalTokens  int64   `json:"total_tokens"`
	TotalCost    float64 `json:"total_cost"`
}

type OverviewResponse

type OverviewResponse struct {
	QPS                      float64              `json:"qps"`
	DailyRequests            int64                `json:"daily_requests"`
	DailyPromptTokens        int64                `json:"daily_prompt_tokens"`
	DailyCompletionTokens    int64                `json:"daily_completion_tokens"`
	DailyCachedTokens        int64                `json:"daily_cached_tokens"`
	DailyCacheCreationTokens int64                `json:"daily_cache_creation_tokens"`
	DailyCost                float64              `json:"daily_cost"`
	AvgLatencyMs             float64              `json:"avg_latency_ms"`
	AvgTTFTMs                float64              `json:"avg_ttft_ms"`
	ActiveCircuitBreakers    []CircuitBreakerInfo `json:"active_circuit_breakers"`
}

type TrendsResponse

type TrendsResponse struct {
	Times  []string       `json:"times"`
	Series []TrendsSeries `json:"series"`
}

type TrendsSeries

type TrendsSeries struct {
	Label   string  `json:"label"`
	Success []int64 `json:"success"`
	Failure []int64 `json:"failure"`
	Total   []int64 `json:"total"`
}

type WSConfigMsg

type WSConfigMsg struct {
	TrendsTimeRange       string `json:"trends_time_range"`
	TrendsGroupBy         string `json:"trends_group_by"`
	ModelRankingSortBy    string `json:"model_ranking_sort_by"`
	ModelRankingTimeRange string `json:"model_ranking_time_range"`
}

WSConfigMsg represents the configuration parameters sent by the client

type WSDashboardPayload

type WSDashboardPayload struct {
	Overview     *OverviewResponse  `json:"overview"`
	Trends       *TrendsResponse    `json:"trends"`
	ModelRanking []ModelRankingItem `json:"model_ranking"`
}

WSDashboardPayload represents the unified push data payload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL