mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-27 14:26:48 +00:00
core[patch]: allow known namespace load from path
This commit is contained in:
@@ -19,6 +19,7 @@ DEFAULT_NAMESPACES = [
|
|||||||
"langchain_anthropic",
|
"langchain_anthropic",
|
||||||
"langchain_groq",
|
"langchain_groq",
|
||||||
"langchain_google_genai",
|
"langchain_google_genai",
|
||||||
|
"langchain_aws",
|
||||||
]
|
]
|
||||||
|
|
||||||
ALL_SERIALIZABLE_MAPPINGS = {
|
ALL_SERIALIZABLE_MAPPINGS = {
|
||||||
@@ -96,16 +97,11 @@ 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 is in mapping, used custom path
|
||||||
if namespace[0] in DEFAULT_NAMESPACES:
|
if (
|
||||||
# Get the importable path
|
namespace[0] in DEFAULT_NAMESPACES
|
||||||
key = tuple(namespace + [name])
|
and (key := tuple(namespace + [name])) in ALL_SERIALIZABLE_MAPPINGS
|
||||||
if key not in ALL_SERIALIZABLE_MAPPINGS:
|
):
|
||||||
raise ValueError(
|
|
||||||
"Trying to deserialize something that cannot "
|
|
||||||
"be deserialized in current version of langchain-core: "
|
|
||||||
f"{key}"
|
|
||||||
)
|
|
||||||
import_path = ALL_SERIALIZABLE_MAPPINGS[key]
|
import_path = ALL_SERIALIZABLE_MAPPINGS[key]
|
||||||
# Split into module and name
|
# Split into module and name
|
||||||
import_dir, import_obj = import_path[:-1], import_path[-1]
|
import_dir, import_obj = import_path[:-1], import_path[-1]
|
||||||
|
Reference in New Issue
Block a user