mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
fix(hidden_params): read private attributes only off a real pydantic class
A spec'd test double passes isinstance(obj, BaseModel) through __class__ while its type has no __private_attributes__, which raised on every hidden params read Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
b6571348e5
commit
e2033586a4
1 changed files with 2 additions and 1 deletions
|
|
@ -63,7 +63,8 @@ def stored_attribute(obj: object, name: str) -> object:
|
|||
def _get_hidden_params_storage(obj: object) -> object | None:
|
||||
if isinstance(obj, dict):
|
||||
return obj.get(_HIDDEN_PARAMS_ATTR)
|
||||
if isinstance(obj, BaseModel) and _HIDDEN_PARAMS_ATTR in type(obj).__private_attributes__:
|
||||
model_type: Final = type(obj)
|
||||
if issubclass(model_type, BaseModel) and _HIDDEN_PARAMS_ATTR in model_type.__private_attributes__:
|
||||
return getattr(obj, _HIDDEN_PARAMS_ATTR, None)
|
||||
return stored_attribute(obj, _HIDDEN_PARAMS_ATTR)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue