api: add /api/v1/metrics endpoint exposing Dashboard metrics (avg_distill_loss, etc.)
This commit is contained in:
parent
90c43c0717
commit
cf31ff5e8e
|
|
@ -304,6 +304,19 @@ func NewServer() http.Handler {
|
|||
mux.HandleFunc("/api/v1/bootstrap", api.Bootstrap)
|
||||
mux.HandleFunc("/api/v1/stats", api.Stats)
|
||||
mux.HandleFunc("/api/v1/batch-commit", api.BatchCommit)
|
||||
// 自优化指标(Dashboard,含 avg_distill_loss)
|
||||
mux.HandleFunc("/api/v1/metrics", func(w http.ResponseWriter, r *http.Request) {
|
||||
m := selfoptimize.Dash.Metrics()
|
||||
if stats, err := ldb.Stats(); err == nil {
|
||||
if total, ok := stats["total_memories"].(float64); ok {
|
||||
m["total_memories"] = total
|
||||
}
|
||||
if total, ok := stats["total_episodes"].(float64); ok {
|
||||
m["total_episodes"] = total
|
||||
}
|
||||
}
|
||||
respondJSON(w, 200, m)
|
||||
})
|
||||
// ─── WebSocket 实时推送 ──────────────────────
|
||||
mux.HandleFunc("/api/v1/ws/", routes.WSHandler)
|
||||
mux.HandleFunc("/api/v1/ws", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue