mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
fix(streaming): guard raise_on_model_repetition against empty choices chunks
Vertex Gemini Flash/Flash Lite with web_search_options emits metadata-only chunks that have choices=[]. These are appended to self.chunks normally, but raise_on_model_repetition unconditionally accesses choices[0] on the last two chunks, raising IndexError on any such metadata chunk. Add an early return when either of the two compared chunks has no choices. The repetition check is meaningless for content-less chunks anyway.
This commit is contained in:
parent
8c6625216b
commit
edf4b885ba
1 changed files with 3 additions and 0 deletions
|
|
@ -269,6 +269,9 @@ class CustomStreamWrapper:
|
|||
if len(self.chunks) < 2:
|
||||
return
|
||||
|
||||
if not self.chunks[-1].choices or not self.chunks[-2].choices:
|
||||
return
|
||||
|
||||
last_content = self.chunks[-1].choices[0].delta.content
|
||||
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue