Closed 1431551850 closed 4 months ago
Hey there, @1431551850! Great to see you diving into another challenge. Let's tackle this one together. 🚀
The error you're encountering is due to the auto_id
parameter being set to False
, which requires a list of valid IDs to be provided for the documents being added. This is indicated by the AssertionError
in the add_texts
function within the langchain_community\vectorstores\milvus.py
file.
To address this issue, you have a few options:
Adjust the auto_id
Setting: If possible, set auto_id = True
to allow Milvus to automatically generate IDs for the documents. This adjustment should be made in the initialization of Milvus within your project's codebase, specifically where the Milvus vector store is being configured.
Provide a List of IDs: If you prefer or need to use custom IDs (with auto_id
set to False
), ensure that your code is correctly generating or retrieving a list of IDs for the documents before they are added to the database.
Check Code Implementation: Review the implementation of the folder2db
function, particularly how it handles document IDs when mode="recreate_vs"
. Ensure it aligns with your ID management strategy (auto-generated vs. custom IDs).
Update Dependencies: Make sure all related dependencies, especially those for Milvus and Langchain, are up to date. Compatibility issues between versions could also lead to this error.
If after trying these steps the issue persists, providing more details about your usage of the folder2db
function and the context in which the error occurs could help in diagnosing the problem further.
KeyError: 'pk',降级到langchain-community-0.0.19
报错KeyError: 'pk的时候,langchain-community本身就是这个0.0.19 版本,降级到langchain-community-0.0.19是什么意思呢,您是不是写错了
KeyError: 'pk',降级到langchain-community-0.0.19
怎么降级呀。我也遇到这个问题了。我是改源码langchain_community\vectorstores\milvus.py,将auto_id = False改为auto_id = True。然后就不再出现这个问题,但是又出现新的问题:KeyError: 'pk'
server.knowledge_base.kb_service.milvus_kb_service.MilvusKBService._load_milvus函数中初始化milvus的时候指定参数auto_id=True,如下:
def _load_milvus(self): self.milvus = Milvus(embedding_function=EmbeddingsFunAdapter(self.embed_model), collection_name=self.kb_name, connection_args=kbs_config.get("milvus"), index_params=kbs_config.get("milvus_kwargs")["index_params"], search_params=kbs_config.get("milvus_kwargs")["search_params"], auto_id=True )
使用的milvus,langchain_community使用0.0.19