diff --git a/router.py b/router.py index cc332f5..c28f750 100644 --- a/router.py +++ b/router.py @@ -2,7 +2,7 @@ title: NOMYO Router - an Ollama Proxy with Endpoint:Model aware routing author: alpha-nerd-nomyo author_url: https://github.com/nomyo-ai -version: 0.4 +version: 0.5 license: AGPL """ # ------------------------------------------------------------- @@ -1164,6 +1164,21 @@ async def show_proxy(request: Request, model: Optional[str] = None): return show # ------------------------------------------------------------- +@app.get("/api/token_counts") +async def token_counts_proxy(): + breakdown = [] + total = 0 + async for entry in db.load_token_counts(): + total += entry['total_tokens'] + breakdown.append({ + "endpoint": entry["endpoint"], + "model": entry["model"], + "input_tokens": entry["input_tokens"], + "output_tokens": entry["output_tokens"], + "total_tokens": entry["total_tokens"], + }) + return {"total_tokens": total, "breakdown": breakdown} + # 12. API route – Stats # ------------------------------------------------------------- @app.post("/api/stats") diff --git a/static/index.html b/static/index.html index bb49d21..a962157 100644 --- a/static/index.html +++ b/static/index.html @@ -256,13 +256,21 @@ .endpoint-distribution-container h3 { margin-top: 0; } + .header-row { + display: flex; + align-items: center; /* vertically center the button with the headline */ + gap: 1rem; + } -

Router Dashboard

+
+

Router Dashboard

+ +