mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
allow other namespaces (#14606)
This commit is contained in:
parent
ce61a8ca98
commit
ad8d8f71aa
@ -63,6 +63,8 @@ class Reviver:
|
|||||||
if len(namespace) == 1 and namespace[0] == "langchain":
|
if len(namespace) == 1 and namespace[0] == "langchain":
|
||||||
raise ValueError(f"Invalid namespace: {value}")
|
raise ValueError(f"Invalid namespace: {value}")
|
||||||
|
|
||||||
|
# If namespace is in known namespaces, try to use mapping
|
||||||
|
if namespace[0] in DEFAULT_NAMESPACES:
|
||||||
# Get the importable path
|
# Get the importable path
|
||||||
key = tuple(namespace + [name])
|
key = tuple(namespace + [name])
|
||||||
if key not in SERIALIZABLE_MAPPING:
|
if key not in SERIALIZABLE_MAPPING:
|
||||||
@ -78,6 +80,10 @@ class Reviver:
|
|||||||
mod = importlib.import_module(".".join(import_dir))
|
mod = importlib.import_module(".".join(import_dir))
|
||||||
# Import class
|
# Import class
|
||||||
cls = getattr(mod, import_obj)
|
cls = getattr(mod, import_obj)
|
||||||
|
# Otherwise, load by path
|
||||||
|
else:
|
||||||
|
mod = importlib.import_module(".".join(namespace))
|
||||||
|
cls = getattr(mod, name)
|
||||||
|
|
||||||
# The class must be a subclass of Serializable.
|
# The class must be a subclass of Serializable.
|
||||||
if not issubclass(cls, Serializable):
|
if not issubclass(cls, Serializable):
|
||||||
|
Loading…
Reference in New Issue
Block a user