localGPT icon indicating copy to clipboard operation
localGPT copied to clipboard

'Collection' object has no attribute '__pydantic_private__',how to solve it?

Open sgf0156 opened this issue 1 year ago • 3 comments

2023-12-05 19:26:23,146 - INFO - run_localgpt.py:241 - Running on: cpu 2023-12-05 19:26:23,146 - INFO - run_localgpt.py:242 - Display Source Documents set to: False 2023-12-05 19:26:23,146 - INFO - run_localgpt.py:243 - Use history set to: False 2023-12-05 19:26:23,553 - INFO - SentenceTransformer.py:66 - Load pretrained SentenceTransformer: hkunlp/instructor-large load INSTRUCTOR_Transformer max_seq_length 512 Traceback (most recent call last): File "C:\Users\shigf\localGPT\run_localgpt.py", line 282, in main() File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\click\core.py", line 1157, in call return self.main(*args, **kwargs) File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) File "C:\Users\shigf\localGPT\run_localgpt.py", line 249, in main qa = retrieval_qa_pipline(device_type, use_history, promptTemplate_type=model_type) File "C:\Users\shigf\localGPT\run_localgpt.py", line 127, in retrieval_qa_pipline db = Chroma( File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\langchain\vectorstores\chroma.py", line 126, in init self._collection = self._client.get_or_create_collection( File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\chromadb\api\segment.py", line 152, in get_or_create_collection return self.create_collection( File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\chromadb\api\segment.py", line 114, in create_collection return Collection( File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\chromadb\api\models\Collection.py", line 53, in init self._client = client File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\pydantic\main.py", line 770, in setattr if self.pydantic_private is None or name not in self.private_attributes: File "C:\Users\shigf\anaconda3\envs\localgpt\lib\site-packages\pydantic\main.py", line 758, in getattr return super().getattribute(item) # Raises AttributeError if appropriate AttributeError: 'Collection' object has no attribute 'pydantic_private'. Did you mean: 'pydantic_complete'?

sgf0156 avatar Dec 05 '23 11:12 sgf0156

I had a similar issue, triggered by this line

assert workflow_db.project == project_db

I had no problem with Pydantic v1, but upgrading to v2 I had to change the assertion like this

assert workflow_db.project.model_dump() == project_db.model_dump()

ychiucco avatar Jan 02 '24 16:01 ychiucco

@ychiucco which file/path are you referring to here ?

nijil avatar Feb 22 '24 16:02 nijil

The problem is that Collection.__init__ doesn't call super().__init__ soon enough. The Pydantic attributes don't exist until that call happens.

rgobbel avatar Apr 11 '24 17:04 rgobbel