Replies: 2 comments 1 reply
-
Hello, @kssgarcia! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together! To resolve the "Invalid namespace" error when implementing human in the loop in your LangChain app using Here is the relevant code snippet from the document: from langchain_mongodb import MongoDBAtlasVectorSearch
from langchain_openai import OpenAIEmbeddings
embedding_model = OpenAIEmbeddings(model="text-embedding-3-small", dimensions=256)
# Vector Store Creation
vector_store = MongoDBAtlasVectorSearch.from_connection_string(
connection_string=MONGO_URI,
namespace=DB_NAME + "." + COLLECTION_NAME, # Ensure this is correctly formatted
embedding=embedding_model,
index_name=ATLAS_VECTOR_SEARCH_INDEX_NAME,
text_key="abstract",
) Make sure that Additionally, the def __call__(self, value: Dict[str, Any]) -> Any:
if (
value.get("lc", None) == 1
and value.get("type", None) == "constructor"
and value.get("id", None) is not None
):
[*namespace, name] = value["id"]
if namespace[0] not in self.valid_namespaces:
raise ValueError(f"Invalid namespace: {value}")
# The root namespace "langchain" is not a valid identifier.
if len(namespace) == 1 and namespace[0] == "langchain":
raise ValueError(f"Invalid namespace: {value}")
# If namespace is in known namespaces, try to use mapping
key = tuple(namespace + [name])
if namespace[0] in DEFAULT_NAMESPACES:
# Get the importable path
if key not in self.import_mappings:
raise ValueError(
"Trying to deserialize something that cannot "
"be deserialized in current version of langchain-core: "
f"{key}"
)
import_path = self.import_mappings[key]
# Split into module and name
import_dir, import_obj = import_path[:-1], import_path[-1]
# Import module
mod = importlib.import_module(".".join(import_dir))
# Import class
cls = getattr(mod, import_obj)
# Otherwise, load by path
else:
if key in self.additional_import_mappings:
import_path = self.import_mappings[key]
mod = importlib.import_module(".".join(import_path[:-1]))
name = import_path[-1]
else:
mod = importlib.import_module(".".join(namespace))
cls = getattr(mod, name)
# The class must be a subclass of Serializable.
if not issubclass(cls, Serializable):
raise ValueError(f"Invalid namespace: {value}")
# We don't need to recurse on kwargs
# as json.loads will do that for us.
kwargs = value.get("kwargs", dict())
return cls(**kwargs)
return value Ensure that the namespace and class names are correctly defined and valid [3]. |
Beta Was this translation helpful? Give feedback.
-
Hey @kssgarcia, could you share your code? Happy to have a look - it looks like you might be storing a chat model in your state? |
Beta Was this translation helpful? Give feedback.
-
I have a simple langgraph app made in TS and I am testing the implementation of human in the loop for this using MongoDBSaver and MemorySaver, but when I add this and the interrupts this error appear:
Beta Was this translation helpful? Give feedback.
All reactions