MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / handle_health

Function handle_health

uncommon_route/proxy.py:3158–3218  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

3156 }
3157
3158 async def handle_health(request: Request) -> JSONResponse:
3159 spend_status = _spend.status()
3160 trace_summary = _traces.summary()
3161 return JSONResponse({
3162 "status": "ok",
3163 "router": "uncommon-route",
3164 "version": VERSION,
3165 "upstream": upstream,
3166 "connections": _current_connection_payload(),
3167 "spending": {
3168 "limits": {k: v for k, v in vars(spend_status.limits).items() if v is not None},
3169 "spent": spend_status.spent,
3170 "remaining": {k: v for k, v in spend_status.remaining.items() if v is not None},
3171 "calls": spend_status.calls,
3172 },
3173 "providers": {
3174 "count": len(_providers.providers),
3175 "names": _providers.provider_names(),
3176 "keyed_models": sorted(_providers.keyed_models()),
3177 },
3178 "selector": _selector_state(),
3179 "routing_config": {
3180 "source": _routing_store.export().get("source", "local-file"),
3181 "editable": _routing_store.export().get("editable", True),
3182 "default_mode": _routing_store.default_mode().value,
3183 },
3184 "stats": {
3185 "total_requests": _stats.count,
3186 },
3187 "traces": {
3188 "total_requests": _traces.count,
3189 "error_count": trace_summary["error_count"],
3190 "virtual_requests": trace_summary["virtual_requests"],
3191 "passthrough_requests": trace_summary["passthrough_requests"],
3192 },
3193 "composition": {
3194 "artifacts": _artifacts.count(),
3195 "semantic_enabled": _semantic is not None,
3196 "policy": _composition_policy.to_dict(),
3197 "sidechannel_models": {
3198 "tool_summary": _composition_policy.sidechannel.tool_summary.candidates(),
3199 "checkpoint": _composition_policy.sidechannel.checkpoint.candidates(),
3200 "rehydrate": _composition_policy.sidechannel.rehydrate.candidates(),
3201 },
3202 },
3203 "feedback": {
3204 "pending": _feedback.pending_count,
3205 "total_updates": _feedback.total_updates,
3206 "online_model": _feedback.online_model_active,
3207 "route_confidence_calibration": _route_confidence.status(),
3208 },
3209 "model_mapper": {
3210 "provider": _mapper.provider,
3211 "is_gateway": _mapper.is_gateway,
3212 "discovered": _mapper.discovered,
3213 "upstream_models": _mapper.upstream_model_count,
3214 "pool_size": _mapper.pool_size,
3215 "unresolved": _mapper.unresolved_models(),

Callers

nothing calls this directly

Calls 13

_selector_stateFunction · 0.85
provider_namesMethod · 0.80
keyed_modelsMethod · 0.80
default_modeMethod · 0.80
candidatesMethod · 0.80
unresolved_modelsMethod · 0.80
statusMethod · 0.45
summaryMethod · 0.45
getMethod · 0.45
exportMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected