You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/documents/base.py:285, in Document.init(self, page_content, **kwargs)
282 """Pass page_content in as positional or named arg."""
283 # my-py is complaining that page_content is not defined on the base class.
284 # Here, we're relying on pydantic base class to handle the validation.
--> 285 super().init(page_content=page_content, **kwargs)
A `RecursionError` was being thrown because `aadd_document` was calling
`aadd_texts` without any changes in its implementation from
`add_documents`. To resolve this, `aadd_document` was removed,
preventing the `RecursionError`, and the base method from `VectorStore`
is now used instead.
Takes care of the following issue:
langchain-ai/langchain#28727
Checked other resources
Example Code
RecursionError Traceback (most recent call last)
Cell In[8], line 6
3 await vectorstore_dvbrby.aadd_documents(documents, ids=uuids)
5 task = asyncio.create_task(add_documents_async(documents))
----> 6 await task
Cell In[8], line 3, in add_documents_async(documents)
2 async def add_documents_async(documents):
----> 3 await vectorstore_dvbrby.aadd_documents(documents, ids=uuids)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_milvus/vectorstores/milvus.py:1557, in Milvus.aadd_documents(self, documents, **kwargs)
1555 texts = [doc.page_content for doc in documents]
1556 metadatas = [doc.metadata for doc in documents]
-> 1557 return await self.aadd_texts(texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/vectorstores/base.py:258, in VectorStore.aadd_texts(self, texts, metadatas, ids, **kwargs)
252 ids_: Iterator[Optional[str]] = iter(ids) if ids else cycle([None])
254 docs = [
255 Document(id=id_, page_content=text, metadata=metadata_)
256 for text, metadata_, id_ in zip(texts, metadatas_, ids_)
257 ]
--> 258 return await self.aadd_documents(docs, **kwargs)
259 return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_milvus/vectorstores/milvus.py:1557, in Milvus.aadd_documents(self, documents, **kwargs)
1555 texts = [doc.page_content for doc in documents]
1556 metadatas = [doc.metadata for doc in documents]
-> 1557 return await self.aadd_texts(texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/vectorstores/base.py:258, in VectorStore.aadd_texts(self, texts, metadatas, ids, **kwargs)
252 ids_: Iterator[Optional[str]] = iter(ids) if ids else cycle([None])
254 docs = [
255 Document(id=id_, page_content=text, metadata=metadata_)
256 for text, metadata_, id_ in zip(texts, metadatas_, ids_)
257 ]
--> 258 return await self.aadd_documents(docs, **kwargs)
259 return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/vectorstores/base.py:258, in VectorStore.aadd_texts(self, texts, metadatas, ids, **kwargs)
252 ids_: Iterator[Optional[str]] = iter(ids) if ids else cycle([None])
254 docs = [
255 Document(id=id_, page_content=text, metadata=metadata_)
256 for text, metadata_, id_ in zip(texts, metadatas_, ids_)
257 ]
--> 258 return await self.aadd_documents(docs, **kwargs)
259 return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_milvus/vectorstores/milvus.py:1557, in Milvus.aadd_documents(self, documents, **kwargs)
1555 texts = [doc.page_content for doc in documents]
1556 metadatas = [doc.metadata for doc in documents]
-> 1557 return await self.aadd_texts(texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/vectorstores/base.py:254, in VectorStore.aadd_texts(self, texts, metadatas, ids, **kwargs)
251 metadatas_ = iter(metadatas) if metadatas else cycle([{}])
252 ids_: Iterator[Optional[str]] = iter(ids) if ids else cycle([None])
--> 254 docs = [
255 Document(id=id_, page_content=text, metadata=metadata_)
256 for text, metadata_, id_ in zip(texts, metadatas_, ids_)
257 ]
258 return await self.aadd_documents(docs, **kwargs)
259 return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/vectorstores/base.py:255, in (.0)
251 metadatas_ = iter(metadatas) if metadatas else cycle([{}])
252 ids_: Iterator[Optional[str]] = iter(ids) if ids else cycle([None])
254 docs = [
--> 255 Document(id=id_, page_content=text, metadata=metadata_)
256 for text, metadata_, id_ in zip(texts, metadatas_, ids_)
257 ]
258 return await self.aadd_documents(docs, **kwargs)
259 return await run_in_executor(None, self.add_texts, texts, metadatas, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/documents/base.py:285, in Document.init(self, page_content, **kwargs)
282 """Pass page_content in as positional or named arg."""
283 # my-py is complaining that page_content is not defined on the base class.
284 # Here, we're relying on pydantic base class to handle the validation.
--> 285 super().init(page_content=page_content, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/load/serializable.py:125, in Serializable.init(self, *args, **kwargs)
123 def init(self, *args: Any, **kwargs: Any) -> None:
124 """"""
--> 125 super().init(*args, **kwargs)
File ~/.pythonlibs/mlrun-base/lib/python3.9/site-packages/langchain_core/documents/base.py:47, in BaseMedia.cast_id_to_str(cls, id_value)
44 @field_validator("id", mode="before")
45 def cast_id_to_str(cls, id_value: Any) -> Optional[str]:
46 if id_value is not None:
---> 47 return str(id_value)
48 else:
49 return id_value
RecursionError: maximum recursion depth exceeded while calling a Python object
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: