mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
docs(api): add ModelMetricsMap type and improve breakdown field documentation
Extract ModelMetricsMap as a named type with documentation comments explaining the map structure and providing examples. Update the TrafficBucket.Breakdown field to use the new type and enhance the GetTrafficChart endpoint description with detailed breakdown field documentation including example usage.
This commit is contained in:
@@ -616,13 +616,18 @@ type TrafficMetrics struct {
|
|||||||
TokensOut int64 `json:"tokens_out"`
|
TokensOut int64 `json:"tokens_out"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ModelMetricsMap is a map from model name to TrafficMetrics.
|
||||||
|
// Keys are model names (e.g. "gpt-4", "claude-3-opus") or "other" for aggregated remaining models.
|
||||||
|
// Example: {"gpt-4": {"count": 10, "tokens_in": 1000, "tokens_out": 500}, "other": {"count": 3, "tokens_in": 200, "tokens_out": 100}}
|
||||||
|
type ModelMetricsMap map[string]TrafficMetrics
|
||||||
|
|
||||||
// TrafficBucket represents one time bucket with model breakdown
|
// TrafficBucket represents one time bucket with model breakdown
|
||||||
type TrafficBucket struct {
|
type TrafficBucket struct {
|
||||||
Time string `json:"time"`
|
Time string `json:"time"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
// Breakdown contains per-model metrics, keyed by model name (e.g. "gpt-4", "claude-3-opus", "other")
|
// Breakdown is a map from model name (e.g. "gpt-4", "claude-3-opus", "other") to its metrics
|
||||||
Breakdown map[string]TrafficMetrics `json:"breakdown" swaggertype:"object,object" example:"{\"gpt-4\":{\"count\":10,\"tokens_in\":1000,\"tokens_out\":500},\"claude-3-opus\":{\"count\":5,\"tokens_in\":800,\"tokens_out\":400},\"other\":{\"count\":3,\"tokens_in\":200,\"tokens_out\":100}}"`
|
Breakdown ModelMetricsMap `json:"breakdown"`
|
||||||
Total TrafficMetrics `json:"total"`
|
Total TrafficMetrics `json:"total"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrafficChartResponse is the response for traffic chart API
|
// TrafficChartResponse is the response for traffic chart API
|
||||||
@@ -641,7 +646,7 @@ const (
|
|||||||
|
|
||||||
// GetTrafficChart godoc
|
// GetTrafficChart godoc
|
||||||
// @Summary Traffic chart data (admin)
|
// @Summary Traffic chart data (admin)
|
||||||
// @Description Get time × model aggregated data for stacked traffic charts. Returns time buckets with per-model breakdown.
|
// @Description Get time × model aggregated data for stacked traffic charts. Returns time buckets with per-model breakdown. The 'breakdown' field in each bucket is a map where keys are model names (e.g. "gpt-4", "claude-3-opus") and values are TrafficMetrics objects. Models outside top_n are aggregated under the key "other". Example: {"gpt-4": {"count": 10, "tokens_in": 1000, "tokens_out": 500}, "other": {"count": 3, "tokens_in": 200, "tokens_out": 100}}
|
||||||
// @Tags admin
|
// @Tags admin
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security AdminAuth
|
// @Security AdminAuth
|
||||||
|
|||||||
Reference in New Issue
Block a user