fix: prevent exception chunk from being passed to _process in astream#547
fix: prevent exception chunk from being passed to _process in astream#5470xCUB3 wants to merge 6 commits intogenerative-computing:mainfrom
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Pop exception from chunks list (like we do for the None sentinel) so _process doesn't receive it. Guard chat_response access in ollama post_processing with .get() for when no valid chunks arrived. Signed-off-by: 0xCUB3 <skula@mit.edu>
151b892 to
f2de636
Compare
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
|
Assigning @avinash2692 to shepherd. The code in other backends is similar so we should verify other backends don't have similar bugs. Some defensive programming in |
Signed-off-by: 0xCUB3 <skula@mit.edu>
Signed-off-by: 0xCUB3 <skula@mit.edu>
… key exists Signed-off-by: 0xCUB3 <skula@mit.edu>
|
Checked all backends for the same pattern, and yes, there were similar issues -- thanks @nrfulton. Found unsafe bracket access on _meta in post_processing for the other backends... openai, litellm, watsonx, huggingface, and vllm. When an exception occurs during streaming, post_processing still runs (finally block) but similarly, _meta keys were never set, so bracket access crashes with KeyError. Fixes:
Ready for review. |
Misc PR
Type of PR
Description
Testing