Skip to content
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

fix(reasoning): compatible with the return data of the reasoning mod… #8286

Closed
wants to merge 0 commits into from

Conversation

kuloud
Copy link

@kuloud kuloud commented Feb 5, 2025

Title

compatible with the return data of the reasoning model

Relevant issues

Fixes #8193

Type

🐛 Bug Fix

Changes

[REQUIRED] Testing - Attach a screenshot of any new tests passing locally

If UI changes, send a screenshot/GIF of working UI fixes

Copy link

vercel bot commented Feb 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 5:17pm

@kuloud
Copy link
Author

kuloud commented Feb 6, 2025

@krrishdholakia Do you think this PR needs to be merged? there aren't many customization scenarios for reasoning_content, and adding a global param doesn't seem necessary for now.

@qtnx
Copy link

qtnx commented Feb 7, 2025

Waiting for this one to be merged to have reasoning output in OpenRouter. Quite long...

@krrishdholakia
Copy link
Contributor

Hi @kuloud can you share a screenshot of this passing your test?

Once done, it should be good to merge

@kuloud
Copy link
Author

kuloud commented Feb 8, 2025

Hi @kuloud can you share a screenshot of this passing your test?

Once done, it should be good to merge

I found that I had some misunderstandings about the implementation within LiteLLM. I tried it and although Delta did handle the mapping of reasoning_content, I don't quite understand where in streaming_handler.py it is processed and the result is ignored.

INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': 'Sure', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     root:test_streaming.py:4104 chunk ----: ModelResponseStream(id='chatcmpl-200e1aaf-b64a-4c3a-bc3c-9e31ca6cfadf', created=1738997695, model='deepseek/deepseek-r1', object='chat.completion.chunk', system_fingerprint=None, choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, content='Sure', role='assistant', function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options=None)
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '!', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     root:test_streaming.py:4104 chunk ----: ModelResponseStream(id='chatcmpl-200e1aaf-b64a-4c3a-bc3c-9e31ca6cfadf', created=1738997695, model='deepseek/deepseek-r1', object='chat.completion.chunk', system_fingerprint=None, choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, content='!', role=None, function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options=None)
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': ' Here', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     root:test_streaming.py:4104 chunk ----: ModelResponseStream(id='chatcmpl-200e1aaf-b64a-4c3a-bc3c-9e31ca6cfadf', created=1738997695, model='deepseek/deepseek-r1', object='chat.completion.chunk', system_fingerprint=None, choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, content=' Here', role=None, function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options=None)
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': "'s", 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     root:test_streaming.py:4104 chunk ----: ModelResponseStream(id='chatcmpl-200e1aaf-b64a-4c3a-bc3c-9e31ca6cfadf', created=1738997695, model='deepseek/deepseek-r1', object='chat.completion.chunk', system_fingerprint=None, choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, content="'s", role=None, function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options=None)
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': '', 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0, 'tool_use': None}
INFO     LiteLLM:streaming_handler.py:871 1--------{'text': ' a', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}
INFO     root:test_streaming.py:4104 chunk ----: ModelResponseStream(id='chatcmpl-200e1aaf-b64a-4c3a-bc3c-9e31ca6cfadf', created=1738997695, model='deepseek/deepseek-r1', object='chat.completion.chunk', system_fingerprint=None, choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, content=' a', role=None, function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options=None)

When processing the reasoning information, it reaches is_async_iterable as shown in the figure, but the chunk information is:
image

{'text': ' a', 'tool_use': None, 'is_finished': False, 'finish_reason': '', 'usage': None, 'index': 0}

@kuloud
Copy link
Author

kuloud commented Feb 8, 2025

This PR doesn't solve the actual problem. It still requires your support @krrishdholakia

@kuloud
Copy link
Author

kuloud commented Feb 10, 2025

This PR doesn't solve the actual problem. It still requires your support @krrishdholakia

I fixed the issue, and maybe I will make an new pr today or tomottow

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.

[Bug]: reasoning_content missing from completion's response
3 participants