refactor(loading.py): add try-except block to handle KeyError when removing 'model' from params dictionary
This commit is contained in:
parent
5cf531b520
commit
bb41f5af5d
1 changed files with 6 additions and 1 deletions
|
|
@ -74,7 +74,12 @@ def instantiate_class(node_type: str, base_type: str, params: Dict) -> Any:
|
||||||
return loaded_toolkit
|
return loaded_toolkit
|
||||||
elif base_type == "embeddings":
|
elif base_type == "embeddings":
|
||||||
# ? Why remove model from params?
|
# ? Why remove model from params?
|
||||||
|
|
||||||
|
try:
|
||||||
params.pop("model")
|
params.pop("model")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
# remove all params that are not in class_object.__fields__
|
# remove all params that are not in class_object.__fields__
|
||||||
try:
|
try:
|
||||||
return class_object(**params)
|
return class_object(**params)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue