mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 16:13:25 +00:00
add getattr case for llms.type_to_cls_dict (#11362)
For external libraries that depend on `type_to_cls_dict`, adds a workaround to continue using the old format. Recommend people use `get_type_to_cls_dict()` instead and only resolve the imports when they're used.
This commit is contained in:
parent
f3e13e7e5a
commit
745e3e29da
@ -617,6 +617,12 @@ def __getattr__(name: str) -> Any:
|
||||
return _import_writer()
|
||||
elif name == "Xinference":
|
||||
return _import_xinference()
|
||||
elif name == "type_to_cls_dict":
|
||||
# for backwards compatibility
|
||||
type_to_cls_dict: Dict[str, Type[BaseLLM]] = {
|
||||
k: v() for k, v in get_type_to_cls_dict().items()
|
||||
}
|
||||
return type_to_cls_dict
|
||||
else:
|
||||
raise AttributeError(f"Could not find: {name}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user