fix(go-models): add stream_options.include_usage for DeepSeek and Azure OpenAI streaming (#17756)

## Summary

DeepSeek and Azure OpenAI require `stream_options.include_usage=true` to
return token usage in streaming responses. Without it, all streaming
calls report zero usage to ClickHouse and the UI shows no token stats.

- [x] Verify DeepSeek streaming calls now report usage
- [x] Verify Azure OpenAI streaming calls now report usage
This commit is contained in:
jay77721
2026-08-04 14:07:17 +08:00
committed by GitHub
parent 3e11914144
commit 3bd1a90b62
2 changed files with 9 additions and 0 deletions

View File

@@ -201,6 +201,11 @@ func (a *AzureOpenAIModel) ChatStreamlyWithSender(ctx context.Context, modelName
}
}
// Request token usage in streaming response. Azure OpenAI only
// includes usage in the final chunk when stream_options.include_usage
// is set.
reqBody["stream_options"] = map[string]any{"include_usage": true}
jsonData, err := json.Marshal(reqBody)
if err != nil {
return fmt.Errorf("failed to marshal request: %w", err)

View File

@@ -192,6 +192,10 @@ func (d *DeepSeekModel) ChatStreamlyWithSender(ctx context.Context, modelName st
}
}
// Request token usage in streaming response. DeepSeek only includes
// usage when stream_options.include_usage is set.
reqBody["stream_options"] = map[string]any{"include_usage": true}
jsonData, err := json.Marshal(reqBody)
if err != nil {
return fmt.Errorf("failed to marshal request: %w", err)