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

@@ -2705,18 +2705,34 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
self.end_headers() self.end_headers()
stream_usage: dict | None = None stream_usage: dict | None = None
observed_stream_tokens = 0 observed_stream_tokens = 0
client_gone = False
try: try:
while True: while True:
line = upstream.readline() line = upstream.readline()
if not line: if not line:
break break
self.wfile.write(line) if not client_gone:
self.wfile.flush() try:
self.wfile.write(line)
self.wfile.flush()
except (BrokenPipeError, ConnectionResetError):
# Keep draining upstream so completed node work is still billed.
client_gone = True
observed, usage = _stream_line_tokens(line) observed, usage = _stream_line_tokens(line)
observed_stream_tokens += observed 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: if usage is not None:
stream_usage = usage stream_usage = usage
except BrokenPipeError: except (BrokenPipeError, ConnectionResetError):
pass 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.