wip -more responsive UI, better routing
This commit is contained in:
@@ -433,6 +433,34 @@ function hiveThroughputSummary(stats) {
|
||||
return { totalTps, samples };
|
||||
}
|
||||
|
||||
function enrichCallWallFromHeartbeat(states, map) {
|
||||
const nodes = (map && map.nodes) || [];
|
||||
for (const node of nodes) {
|
||||
const reqs = (node.stats && node.stats.current_requests) || [];
|
||||
for (const req of reqs) {
|
||||
const id = req.request_id;
|
||||
if (!id) continue;
|
||||
let rec = states.get(id);
|
||||
if (!rec) {
|
||||
rec = {
|
||||
id,
|
||||
events: [],
|
||||
status: "processing",
|
||||
started: Date.now() / 1000 - Number(req.elapsed_seconds || 0),
|
||||
model: req.model || node.model || "?",
|
||||
};
|
||||
states.set(id, rec);
|
||||
} else if (rec.status === "pending") {
|
||||
rec.status = "processing";
|
||||
}
|
||||
if (req.model) rec.model = req.model;
|
||||
if (req.tokens != null) rec.tokens = req.tokens;
|
||||
if (req.tokens_per_sec != null) rec.tps = req.tokens_per_sec;
|
||||
if (req.elapsed_seconds != null) rec.elapsed = req.elapsed_seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildCallWallStates(events) {
|
||||
const byId = new Map();
|
||||
for (const e of events) {
|
||||
@@ -453,7 +481,7 @@ function buildCallWallStates(events) {
|
||||
rec.route = f.route || f.nodes;
|
||||
rec.nodes = f.nodes;
|
||||
rec.stream = f.stream;
|
||||
} else if (msg === "proxy via relay" || msg === "proxy connected") {
|
||||
} else if (msg === "proxy via relay" || msg === "proxy connected" || msg === "proxy connecting") {
|
||||
rec.status = "processing";
|
||||
if (!rec.started) rec.started = e.ts;
|
||||
rec.model = rec.model || f.model || f.route_model || "?";
|
||||
@@ -539,10 +567,11 @@ function renderRouting(routing) {
|
||||
el.innerHTML = html;
|
||||
}
|
||||
|
||||
function renderCallWall(consoleData, stats) {
|
||||
function renderCallWall(consoleData, stats, map) {
|
||||
const events = (consoleData && consoleData.events) || [];
|
||||
const nowSec = Date.now() / 1000;
|
||||
const states = buildCallWallStates(events);
|
||||
enrichCallWallFromHeartbeat(states, map);
|
||||
const active = [];
|
||||
const terminal = [];
|
||||
for (const rec of states.values()) {
|
||||
@@ -577,7 +606,7 @@ function renderCallWall(consoleData, stats) {
|
||||
const note = rec.warn || (rec.route ? short(String(rec.route), 28) : "");
|
||||
const row = [
|
||||
`<span class="${statusCls}">${esc(rec.status)}</span>`,
|
||||
`<span class="num">${esc(callWallAgeSeconds(rec, nowSec).toFixed(1))}s</span>`,
|
||||
`<span class="num">${esc(rec.elapsed != null ? Number(rec.elapsed).toFixed(1) : callWallAgeSeconds(rec, nowSec).toFixed(1))}s</span>`,
|
||||
esc(short(rec.model || "?", 28)),
|
||||
esc(short(rec.id, 18)),
|
||||
`<span class="num">${esc(tps(rec.tps))}</span>`,
|
||||
@@ -1513,7 +1542,7 @@ async function refresh() {
|
||||
renderFraud(wallets, summary);
|
||||
renderStats(stats);
|
||||
renderRouting(routing);
|
||||
renderCallWall(consoleData, stats);
|
||||
renderCallWall(consoleData, stats, map);
|
||||
renderConsole(consoleData);
|
||||
renderNodeThroughput(stats);
|
||||
renderChatModels();
|
||||
|
||||
@@ -3257,6 +3257,14 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
try:
|
||||
started = time.monotonic()
|
||||
_tracker_log(
|
||||
server,
|
||||
"info",
|
||||
"proxy connecting",
|
||||
request_id=request_id,
|
||||
target_url=target_url,
|
||||
stream=is_stream or None,
|
||||
)
|
||||
upstream_result: list[Any] = []
|
||||
connect_errors: list[BaseException] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user