File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1348,7 +1348,8 @@ func (m *Model) shouldSuppressChunk(chunk openai.ChatCompletionChunk) bool {
13481348// 2. Check content - if valid, don't skip (even if empty string)
13491349// 3. Check refusal - if valid, don't skip
13501350// 4. Check toolcalls - if valid but array is empty, skip (defensive against panic)
1351- // 5. Otherwise, skip
1351+ // 5. Check usage - if valid, don't skip
1352+ // 6. Otherwise, skip
13521353func (m * Model ) shouldSkipEmptyChunk (chunk openai.ChatCompletionChunk ) bool {
13531354 // No choices available, don't skip (let it be processed normally).
13541355 if len (chunk .Choices ) == 0 {
@@ -1373,6 +1374,10 @@ func (m *Model) shouldSkipEmptyChunk(chunk openai.ChatCompletionChunk) bool {
13731374 return len (delta .ToolCalls ) == 0
13741375 }
13751376
1377+ if chunk .Usage .CompletionTokens > 0 || chunk .Usage .PromptTokens > 0 || chunk .Usage .TotalTokens > 0 {
1378+ return false
1379+ }
1380+
13761381 // Otherwise there is no meaningful delta, skip the chunk.
13771382 return true
13781383}
You can’t perform that action at this time.
0 commit comments