Fix R1 reasoning parser for openai client - #5961
Eric Zhu (ekzhu) merged 7 commits into
Conversation
|
For the 400 server error about alternating user-assistant roles in messages, let's use this issue :#5965 |
06df01e to
f450a77
Compare
f450a77 to
e5cb30f
Compare
|
Hey Eric, I have applied the requested changes if there is anything else let me know. |
Eric Zhu (ekzhu)
left a comment
There was a problem hiding this comment.
Could you add a unit test, to validate that create and create_stream use reasoning_content when available.
See example here: https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/tests/models/test_openai_model_client.py#L890-L891
|
We can only merge the PR if you agree to the CLA, see automated comment above. |
|
Please read the python developer guide for formatting and type checking: https://github.com/microsoft/autogen/blob/main/python/README.md cd python/packages/autogen-ext
poe pyright
poe mypy
poe format
poe lint |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5961 +/- ##
==========================================
+ Coverage 76.65% 76.67% +0.02%
==========================================
Files 191 191
Lines 13129 13141 +12
==========================================
+ Hits 10064 10076 +12
Misses 3065 3065
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@microsoft-github-policy-service agree |
|
Hey Eric Zhu (@ekzhu) can you please run the format check, just want to see if that fixes it, I am not using uv atm, so I got the Ruff extension and applied that but it changed quite a bit on the file formatting. |
Added tests for the handling of reasoning_content for R1 model
|
Tests added and formatting should be fixed but let me know if there is anything else |
|
Thanks. There is a few formatting and type checking issues remaining. Have you tried to use uv to set up the development environment? |
|
The type checking issues are interesting because they relate to reasoning_content not being defined in ChatCompletionMessage (For the test file only as we are basically trying to emulate deepseek's api) which it probably thinks is a problem but this is not the case when using Pydantic as the reasoning_content data is added to model_extra and that is what we are using. So my thought and I don't like doing this but is either a comment on the code # type: ignore[call-arg] to say ignore type check for these two lines or leave as is and skip the test. Let me know what you think about this and if you have any ideas to fix it. |
|
Okay format issues should (third time lucky) be fixed. I got uv and poe running locally and fixed the formatting issues. |
Eric Zhu (ekzhu)
left a comment
There was a problem hiding this comment.
y26s4824k264, please continue your PR from this one once merged.
Hey Eric Zhu (@ekzhu), can you please have a look at this. This resolves the issues with parsing of the R1 reasoning tokens at least for openai client there are still areas where it still uses the old parser which need to be look at in the future. This doesn't fully resolve all the issues mentioned previously however the parsing of reasoning tokens should now be resolved.
Why are these changes needed?
R1 reasoning tokens were not parsed correctly for the openai client
Related issue number
#5941
Checks