ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8b70b7d976 |
usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now keeps what each request received back (down_bytes) beside what it sent up (up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the upload (image_files_saved). Shown in Usage → Requests: - a row's details: "Sent upstream", "Received" and "Saved by image files", each only when it is above 0. A row from before has none of them, not 0; - under the Requests card, the period's "↑ up · ↓ down", with "{n} saved by image files" when there is a saving. Its title gives the exact bytes. A period with no counted bytes shows no line. What is counted: - Down bytes are counted as the reply body is read, after Go's transport has undone gzip, so a gzipped reply counts its plain size, not wire bytes. A plugin's row counts the local hop to the plugin host. A 101 body is not wrapped. Every try counts, so a refused try plus the answering one add up (TestLedgerKeepsDownBytes). - Image files saved, per try: the body before the swap minus the body sent, minus the upload bytes this request itself paid (len(b64)/4*3). It can be negative on the turn that uploads; the GUI shows only a saving above 0. Gaps: an upload that finishes after the wait timeout or ctx-done is not subtracted (as with up_bytes); a joined upload flight is paid by the request that started it; multipart overhead is approximate. - packedRow grows by three int32 (152 bytes, still within the test's bound), clamped to the int32 range. Totals sum all three. - settledCountVersion goes 1 → 2, because Totals now count bytes. The settled page, heat and effort caches recount once, on the first start after the update. The heat key hash includes the new fields. Run on mote at |
||
|
|
4bac5eed26 |
usage: a request's row says what went up to the vendor, tries summed (#4456)
RunMintOn asked how much a long session sends upstream: a proxy counted ~900 MB up in 45 minutes, and no ledger row said what a request sent. A row now has up_bytes, the bytes that went on the wire, every try and every second ask summed (zstd's size for a ChatGPT turn), and plain_bytes, the last try's body before compression. They are summed in the request's context on its own goroutine, set in serve and, for Codex's own turns that come from the mux and not through serve, in codexUpstreamOn. Handed-on rows carry neither; rows from before carry neither. From ggbdpq's patch (via gua2100), two changes: - the patch counted in codexUpstreamOn but set the context only in serve, so a Codex turn on its ChatGPT sign-in, the zstd case the issue is about, wrote 0 and 0 (TestCodexOwnTurnKeepsUpBytes); - a second request inside one try (RetryOneAuth, RetryZhipuCoding, RetryOpenCodeFreeOnZen) went up uncounted; it counts now (TestLedgerCountsATrysSecondAsk). Request bodies to other vendors stay as their client sent them; zstd stays Codex's (the owner's call, on the issue). Run at this tree on mote: go test ./internal/gateway -run 'UpBytes|TrysSecondAsk|OneAuth|Codex|Draw|Relay' -count=1: ok; go test ./internal/usage ./internal/redact -count=1: ok. gofmt clean. Broken by hand: no context in serve: TestLedgerKeepsUpBytes and TestLedgerCountsATrysSecondAsk red; none in codexUpstreamOn: TestCodexOwnTurnKeepsUpBytes red (row 0/0, backend got 79 of 8444); the second ask not counted: TestLedgerCountsATrysSecondAsk red. Not tried: a real session's numbers against a proxy's; the GUI shows neither field yet. Co-authored-by: ggbdpq <ggbdpq@gmail.com> |