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.
pull/11360/head^2
Erick Friis 1 year ago committed by GitHub
parent f3e13e7e5a
commit 745e3e29da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -617,6 +617,12 @@ def __getattr__(name: str) -> Any:
return _import_writer() return _import_writer()
elif name == "Xinference": elif name == "Xinference":
return _import_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: else:
raise AttributeError(f"Could not find: {name}") raise AttributeError(f"Could not find: {name}")

Loading…
Cancel
Save