-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle azure deepseek reasoning response #8288
Handle azure deepseek reasoning response #8288
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
@@ -415,8 +416,17 @@ def convert_to_model_response_object( # noqa: PLR0915 | |||
for field in choice["message"].keys(): | |||
if field not in message_keys: | |||
provider_specific_fields[field] = choice["message"][field] | |||
|
|||
# Handle reasoning models that display `reasoning_content` within `content`` | |||
content = choice["message"].get("content", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have this be in a separate helper function - it'll be easier to add a unit test for this as well
Thank you for the work on this @vibhavbhat - if you can just refactor the check to be in a separate helper function and add a direct test for that (prevents any future regression), i think we should be good! |
@krrishdholakia Added helper + unit tests |
@krrishdholakia is this good to merge? |
dfb0266
into
BerriAI:litellm_dev_02_07_2025_p1
* Handle azure deepseek reasoning response (#8288) * Handle deepseek reasoning response * Add helper method + unit test * Fix: Follow infinity api url format (#8346) * Follow infinity api url format * Update test_infinity.py * fix(infinity/transformation.py): fix linting error --------- Co-authored-by: vibhavbhat <[email protected]> Co-authored-by: Hao Shan <[email protected]>
Title
Relevant issues
Fixes #8267
Type
π New Feature
π Bug Fix
β Test
Changes
Some deepseek model hosts (specifically Azure) returns the reasoning content within the content itself as
<think>Thinking Content<think>User facing response
. This PR properly handles that case and puts the reasoning content on the api response as intended. This fix should work in general for all hosts that set the reasoning content like this.[REQUIRED] Testing - Attach a screenshot of any new tests passing locally
If UI changes, send a screenshot/GIF of working UI fixes
Added test w/ reasoning content and it passed
![image](https://private-user-images.githubusercontent.com/10468083/410137554-1dba94d1-165e-487b-b1e1-170e56d03878.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc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1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDIxMTkxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNkMzhlNWU0N2VjYTMxODdjOGRhNTg2ODdkYWJlYTQxM2E1MTU1YWZiMWE4OWU0MTI2YzgzM2IyZjUxNDJlMGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.gjIJ0xJ5hfiGyXoEXS0j9tdf4azNBLF1KV1pXgt0WoA)
Unit test for helper also passes
![image](https://private-user-images.githubusercontent.com/10468083/410344405-855bda61-b41f-492c-a19d-3ced121bad16.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NTQ2NTEsIm5iZiI6MTczOTY1NDM1MSwicGF0aCI6Ii8xMDQ2ODA4My80MTAzNDQ0MDUtODU1YmRhNjEtYjQxZi00OTJjLWExOWQtM2NlZDEyMWJhZDE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDIxMTkxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5YWQxMGFjNDFmMzQ3MmEzNDNjMzBkM2UzNTVhNTg5NDhkOWM2MjkxNmU0MjQxY2ZmNWJiNTg2NDE4NWRhYWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.klcqglIeElJ0JTrAbdAHAos-2zVXQ4onVWiheqZCL8s)