mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
Carry an additive usage envelope on the SSE done frame
({ totalTokens, model }) and persist tokensUsed + model onto
coach_messages (migration 0182, nullable, no backfill) so the
per-message token footer survives a conversation reload. Add an
optional reasoning frame the client can render inside the thinking
disclosure when a reasoning-capable provider emits a summary; providers
without reasoning emit none. Extend CoachMessageDTO and regenerate the
OpenAPI contract. Server-authoritative: clients display the count, never
recompute it.
15 lines
690 B
SQL
15 lines
690 B
SQL
-- v1.18.9 — per-message Coach token usage + model.
|
|
--
|
|
-- The streaming chat endpoint already computes the per-turn token count
|
|
-- (`result.tokensUsed`) and the model that produced the reply, but until
|
|
-- now neither reached the client. Two additive nullable columns let the
|
|
-- quiet per-message token footer survive a conversation reload: the live
|
|
-- turn paints from the `done.usage` SSE frame, persisted history paints
|
|
-- from these columns.
|
|
--
|
|
-- Both NULL by default. No backfill: existing rows (and every user turn
|
|
-- or refusal, which never carries a token count) simply render no footer.
|
|
ALTER TABLE "coach_messages"
|
|
ADD COLUMN "tokens_used" INTEGER,
|
|
ADD COLUMN "model" TEXT;
|