Skip to content

Default usage statistics for streaming responses#6578

Merged
peterychang merged 11 commits into
microsoft:mainfrom
peterychang:default_stream_usage
May 28, 2025
Merged

Default usage statistics for streaming responses#6578
peterychang merged 11 commits into
microsoft:mainfrom
peterychang:default_stream_usage

Conversation

@peterychang
Copy link
Copy Markdown
Contributor

Why are these changes needed?

Enables usage statistics for streaming responses by default.

There is a similar bug in the AzureAI client. Theoretically adding the parameter

model_extras={"stream_options": {"include_usage": True}}

should fix the problem, but I'm currently unable to test that workflow

Related issue number

closes #6548

Checks

@peterychang peterychang requested a review from ekzhu May 22, 2025 18:00
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.53%. Comparing base (9bbcfa0) to head (35fd3d2).
⚠️ Report is 139 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6578   +/-   ##
=======================================
  Coverage   79.53%   79.53%           
=======================================
  Files         225      225           
  Lines       16650    16656    +6     
=======================================
+ Hits        13242    13248    +6     
  Misses       3408     3408           
Flag Coverage Δ
unittests 79.53% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread python/packages/autogen-ext/tests/models/test_openai_model_client.py Outdated
Comment thread python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py Outdated
@peterychang
Copy link
Copy Markdown
Contributor Author

It looks like we actually have documentation around the behavior of create_stream
https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/src/autogen_ext/models/openai/_openai_client.py#L751

I added a flag to enable the behavior more easily, defaulted to False to preserve current behavior

@peterychang peterychang merged commit 03394a4 into microsoft:main May 28, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

models_usage shows prompt_tokens and completion_tokens as 0

3 participants