Documentation
¶
Index ¶
- type BYOKOverviewResponse
- type DashboardRequest
- type DashboardResponse
- type Handler
- func (h *Handler) BYOKOverview(c *app.Context, _ api.EmptyRequest) (BYOKOverviewResponse, error)
- func (h *Handler) Dashboard(c *app.Context, req DashboardRequest) (DashboardResponse, error)
- func (h *Handler) Overview(c *app.Context, _ api.EmptyRequest) (OverviewResponse, error)
- func (h *Handler) Trend(c *app.Context, req TrendRequest) (TrendResponse, error)
- type LeaderboardBlock
- type OverviewResponse
- type SpeedCompareBlock
- type TrendBlock
- type TrendRequest
- type TrendResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BYOKOverviewResponse ¶ added in v0.0.2
type BYOKOverviewResponse struct {
Requests int64 `json:"requests"`
TotalCost int64 `json:"total_cost"`
}
BYOKOverviewResponse holds aggregated BYOK usage stats for the current user. Kept for backward-compat with the original /api/stats/byok-overview endpoint; new clients should use /api/private-channels/billing/overview which returns KPI + daily time series.
type DashboardRequest ¶ added in v0.0.2
type DashboardRequest struct {
Start int64 `form:"start"`
End int64 `form:"end"`
Gran string `form:"gran"`
Model string `form:"model"`
UserID uint `form:"user_id"`
}
DashboardRequest 是 /v1/stats/dashboard 的入参。 start/end 为 unix 秒;end 缺省取 now、start 缺省取 end-86400;gran 缺省 "day"。
type DashboardResponse ¶ added in v0.0.2
type DashboardResponse struct {
Kpis dao.KpiBundle `json:"kpis"`
Trend TrendBlock `json:"trend"`
ModelDistribution []dao.Bucket `json:"model_distribution,omitempty"`
Leaderboard *LeaderboardBlock `json:"leaderboard,omitempty"`
SpeedCompare *SpeedCompareBlock `json:"speed_compare,omitempty"`
}
DashboardResponse 是 /v1/stats/dashboard 的统一返回。 admin scope 返回全部字段;user scope 仅 Kpis + Trend,其余 omitempty。
type Handler ¶
type Handler struct {
ConnectedCount func() int
}
func (*Handler) BYOKOverview ¶ added in v0.0.2
func (h *Handler) BYOKOverview(c *app.Context, _ api.EmptyRequest) (BYOKOverviewResponse, error)
BYOKOverview returns private-channel usage summary for the authenticated user.
Task 19+ moved the source of truth from usage_logs to channel_daily_billings. Reusing ListPrivateChannelDailyByOwner keeps this endpoint consistent with the new /private-channels/billing/* endpoints (same rows, same scoping rules) at the cost of one extra SUM in Go — the per-user row count is negligible.
func (*Handler) Dashboard ¶ added in v0.0.2
func (h *Handler) Dashboard(c *app.Context, req DashboardRequest) (DashboardResponse, error)
Dashboard 组合 Phase 2 的 DAO 方法 (DashboardKpis / HourlyTrend / Distribution / Leaderboard / SpeedCompare),按 admin/user scope 返回不同的字段集。
admin: 全部字段 (kpis + trend + model_distribution + leaderboard + speed_compare)。 user: 仅 kpis + trend;admin-only 字段通过 omitempty 隐藏。
窗口超过 ObsRange.Validate() 上限时返回 400 RangeOutOfBounds (结构化 code,前端 i18n 用)。
func (*Handler) Overview ¶
func (h *Handler) Overview(c *app.Context, _ api.EmptyRequest) (OverviewResponse, error)
func (*Handler) Trend ¶
func (h *Handler) Trend(c *app.Context, req TrendRequest) (TrendResponse, error)
type LeaderboardBlock ¶ added in v0.0.2
type LeaderboardBlock struct {
Users []dao.LeaderRow `json:"users"`
Models []dao.LeaderRow `json:"models"`
Channels []dao.LeaderRow `json:"channels"`
AvailableMetrics []string `json:"available_metrics"`
}
LeaderboardBlock 聚合三个维度 (user/model/channel) 的 cost top10 + 可选 metric 列表。
type OverviewResponse ¶
type OverviewResponse struct {
// Admin-only fields (nil for normal users)
Users *int64 `json:"users,omitempty"`
Channels *int64 `json:"channels,omitempty"`
Models *int64 `json:"models,omitempty"`
Agents *int64 `json:"agents,omitempty"`
ConnectedAgents *int `json:"connected_agents,omitempty"`
// Common fields
Tokens int64 `json:"tokens"`
UsageLogs int64 `json:"usage_logs"`
TotalCost int64 `json:"total_cost"`
// User-only fields (nil for admin)
Quota *int64 `json:"quota,omitempty"`
UsedQuota *int64 `json:"used_quota,omitempty"`
}
type SpeedCompareBlock ¶ added in v0.0.2
type SpeedCompareBlock struct {
ByModel []dao.SpeedRow `json:"by_model"`
ByChannel []dao.SpeedRow `json:"by_channel"`
}
SpeedCompareBlock 聚合 model/channel 维度 SpeedCompare。
type TrendBlock ¶ added in v0.0.2
type TrendBlock struct {
Buckets []dao.TimeBucket `json:"buckets"`
Metrics []string `json:"metrics"`
}
TrendBlock 包含 HourlyTrend 输出 + 当前可选 metric 列表(前端 metric 切换用)。
type TrendRequest ¶
type TrendRequest struct {
Days string `form:"days"`
}