Files
ragflow/internal
jay77721 57b3a7384d fix(go-models): record Novita streaming usage without chatConfig (#17778)
Relate to #17284.

## Problem

`novitaHandleStream` guarded usage recording with `if found &&
chatConfig != nil`. When a caller passes a nil `*ChatConfig` — common in
the service layer (`model_chat.go`, `chat_pipeline.go`) — the streamed
token usage is dropped entirely.

The shared `HandleStreamingResponse` only uses `chatConfig` to expose
`UsageResult` and records usage whenever the stream carries it. Novita's
bespoke handler diverged from every other OpenAI-compatible streaming
driver.

## Fix

Record usage whenever the stream carries a usage event, mirroring
`HandleStreamingResponse`. `applyStreamUsage` already handles a nil
`chatConfig` internally (it only writes `chatConfig.UsageResult` when
non-nil), so the extra guard was doing nothing but dropping usage.

## Test

`TestNovitaStreamRecordsUsageWithoutChatConfig`:
- nil `chatConfig` + usage event → stream completes without error (guard
removed safely)
- non-nil `chatConfig` + usage event → `UsageResult` populated with the
streamed tokens

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-04 14:42:16 +08:00
..
2026-08-03 15:08:21 +08:00
2026-08-01 22:06:56 +08:00
2026-08-03 21:30:01 +08:00
2026-08-04 14:18:03 +08:00
2026-08-03 21:30:01 +08:00
2026-08-03 21:30:01 +08:00
2026-08-04 14:24:01 +08:00
2026-07-27 10:20:16 +08:00
2026-08-03 21:30:01 +08:00
2026-08-03 17:39:47 +08:00
2026-08-02 00:31:21 +08:00