Commit Graph
5 Commits
Author SHA1 Message Date
jie65535andClaude Opus 4.8 13329b5fa3 Track cache-hit tokens and consolidate token stats into one dashboard
Capture DeepSeek's prompt_cache_hit_tokens (dropped before by the
openai-kotlin Usage parser) via a raw-JSON extractor in ModelService,
and persist it plus the group name on each daily record.

Collapse the six /jgpt tokens* subcommands into a single /jgpt tokens
dashboard showing cache-hit rate, input/output split, daily trend and
top users/groups. Groups are shown by name only, never by group id.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-23 23:01:16 +08:00
jie65535andClaude Opus 4.8 a29cf17361 Release ByteReadChannel when first-chunk timeout fires
The streaming refactor moved post()+body() inside withTimeout, so a
first-chunk timeout threw before `channel` was bound and the finally
guard never ran, leaking the connection on every slow-API retry. Hold
the channel in an outer nullable var and wrap the whole flow in
try/finally so an acquired channel is always cancelled.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-20 23:56:11 +08:00
jie65535andClaude Opus 4.8 eedbd55f62 Fix streaming first-token timeout never firing on slow API
The firstChunkTimeout only wrapped the response-body read, but when the
upstream (e.g. DeepSeek under load) stalls before sending response
headers, httpClient.post() itself blocks and the withTimeout block is
never reached. Every slow request fell through to Ktor's
requestTimeoutMillis (120s) and was retried up to retryMax times,
causing multi-minute waits before any reply.

- Move post() inside withTimeout(firstChunkTimeout) so the entire
  request-to-first-data-chunk window is bounded and fails fast.
- Apply withTimeout(firstChunkTimeout) to each streaming read so a
  mid-stream stall is also caught quickly instead of waiting on the
  socket/request backstop.
- Drop requestTimeoutMillis so legitimately long streams are no longer
  killed at 120s; TTFT and inter-token gaps are now governed at the
  application layer.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-20 22:01:44 +08:00
jie65535 72892336bc Add first-chunk timeout 2026-05-22 14:16:00 +08:00
jie65535 e5d5445a1f Add ModelService with extra body support 2026-05-22 14:15:12 +08:00