show all requests not just histroy

This commit is contained in:
Dobromir Popov
2026-07-07 15:51:58 +02:00
parent 640ef78711
commit 6fa69aecaa

View File

@@ -2702,22 +2702,38 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "text/event-stream; charset=utf-8") self.send_header("Content-Type", "text/event-stream; charset=utf-8")
self.send_header("Cache-Control", "no-cache") self.send_header("Cache-Control", "no-cache")
self.end_headers() self.end_headers()
stream_usage: dict | None = None stream_usage: dict | None = None
observed_stream_tokens = 0 observed_stream_tokens = 0
try: client_gone = False
while True: try:
line = upstream.readline() while True:
if not line: line = upstream.readline()
break if not line:
self.wfile.write(line) break
self.wfile.flush() if not client_gone:
observed, usage = _stream_line_tokens(line) try:
observed_stream_tokens += observed self.wfile.write(line)
if usage is not None: self.wfile.flush()
stream_usage = usage except (BrokenPipeError, ConnectionResetError):
except BrokenPipeError: # Keep draining upstream so completed node work is still billed.
pass client_gone = True
observed, usage = _stream_line_tokens(line)
observed_stream_tokens += observed
if observed:
_tracker_log_proxy_progress(
server,
request_id=request_id,
model=model,
route_model=route_model,
tokens=observed_stream_tokens,
started=started,
route_nodes=route_nodes,
)
if usage is not None:
stream_usage = usage
except (BrokenPipeError, ConnectionResetError):
pass
elapsed = time.monotonic() - started elapsed = time.monotonic() - started
# Bill even on client disconnect — the nodes did the work. # Bill even on client disconnect — the nodes did the work.
# Observed stream chunks are authoritative for the upper bound; # Observed stream chunks are authoritative for the upper bound;