mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-28 04:04:31 +00:00
fix(utils.py): handle pydantic v1
This commit is contained in:
parent
2c2e4319ab
commit
ec548df1d6
1 changed files with 4 additions and 1 deletions
|
@ -10194,7 +10194,10 @@ class CustomStreamWrapper:
|
||||||
for idx, choice in enumerate(original_chunk.choices):
|
for idx, choice in enumerate(original_chunk.choices):
|
||||||
try:
|
try:
|
||||||
if isinstance(choice, BaseModel):
|
if isinstance(choice, BaseModel):
|
||||||
choice_json = choice.model_dump()
|
try:
|
||||||
|
choice_json = choice.model_dump()
|
||||||
|
except Exception as e:
|
||||||
|
choice_json = choice.dict()
|
||||||
choice_json.pop(
|
choice_json.pop(
|
||||||
"finish_reason", None
|
"finish_reason", None
|
||||||
) # for mistral etc. which return a value in their last chunk (not-openai compatible).
|
) # for mistral etc. which return a value in their last chunk (not-openai compatible).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue