chroma-core / chroma

the AI-native open-source embedding database
https://www.trychroma.com/
Apache License 2.0
13.66k stars 1.15k forks source link

[Bug]: 'Chroma' object has no attribute 'persist' #2012

Closed rachelshirin007 closed 2 months ago

rachelshirin007 commented 3 months ago

What happened?

I'm persisting the Chroma Database but it's giving me an error in jupyter notebook.

I'm basically redoing what's in this link.

https://github.com/hwchase17/chroma-langchain/blob/master/persistent-qa.ipynb

Is there any update in chromadb version and they have removed persist I don't get it.

!pip -q install chromadb openai langchain tiktoken

!pip install -q langchain-chroma

!pip install -q langchain_chroma  langchain_openai langchain_community

from langchain_chroma import Chroma
from langchain_openai import OpenAI
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.document_loaders import TextLoader
from langchain_community.document_loaders import DirectoryLoader

persist_directory ='db'

embedding = OpenAIEmbeddings()

vectordb = Chroma.from_documents(documents=texts,
                                 embedding=embedding,
                                 persist_directory=persist_directory)

vectordb.persist()

Then I'm getting the below error:


AttributeError Traceback (most recent call last) Cell In[47], line 1 1 vectordb.persist()

AttributeError: 'Chroma' object has no attribute 'persist'

Versions

langchain-chroma 0.1.0 chromadb 0.4.24 Python 3.9.19 Windows 64-bit os

Relevant log output

No response

tazarov commented 3 months ago

In 0.4.x, Chroma no longer supports the manual persistence method, so you should not be calling it if you use newer Chroma and LC. Don't worry your data is saved the moment the docs are added to Chroma with Chroma.from_documents.