mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-04 23:00:30 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user