chroma-core / chroma

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

[Bug]: AttributeError: module 'chromadb' has no attribute 'config' #1614

Open XariZaru opened 8 months ago

XariZaru commented 8 months ago

What happened?

Issue when creating Chroma object. Error is: AttributeError: module 'chromadb' has no attribute 'config'

vectorstore = Chroma(
        collection_name=collection_name, 
        embedding_function=get_embedding_function(), 
        persist_directory="storage/deploy/chroma-db"
    )

Versions

Chroma v0.4.22, Python 3.11

Relevant log output

AttributeError                            Traceback (most recent call last)
Cell In[1], line 28
     20     retriever = ParentDocumentRetriever(
     21         vectorstore=vectorstore,
     22         docstore=store,
     23         child_splitter=child_splitter,
     24         parent_splitter=parent_splitter
     25     )
     26     return retriever
---> 28 retriever = load_chroma_db("full_docs")
     29 retriever.add_documents(bancworks_docs)
     30 # retriever.add_documents(bancworks_docs)
     31 # retriever.add_documents(bancworks_docs)
Cell In[1], line 13, in load_chroma_db(collection_name)
     10 parent_splitter = RecursiveCharacterTextSplitter(chunk_size=2000)
     11 child_splitter = RecursiveCharacterTextSplitter(chunk_size=400)
---> 13 vectorstore = Chroma(
     14     collection_name=collection_name, 
     15     embedding_function=get_embedding_function(), 
     16     persist_directory="storage/deploy/chroma-db"
     17 )
     18 store = InMemoryStore()
     20 retriever = ParentDocumentRetriever(
     21     vectorstore=vectorstore,
     22     docstore=store,
     23     child_splitter=child_splitter,
     24     parent_splitter=parent_splitter
     25 )
File /etc/system/kernel/.venv/lib64/python3.11/site-packages/langchain_community/vectorstores/chroma.py:115, in Chroma.__init__(self, collection_name, embedding_function, persist_directory, client_settings, collection_metadata, client, relevance_score_fn)
    111         _client_settings = chromadb.config.Settings(
    112             chroma_db_impl="duckdb+parquet",
    113         )
    114     else:
--> 115         _client_settings = chromadb.config.Settings(is_persistent=True)
    116     _client_settings.persist_directory = persist_directory
    117 else:
AttributeError: module 'chromadb' has no attribute 'config'
tazarov commented 8 months ago

hey @XariZaru, are you sure Chroma is installed? I've tested with your setup and the latest version of Langchain; it appears to be working. Here's a colab notebook I've tested with https://colab.research.google.com/drive/1V6mhBOqCn6WonhnDKnAfP8lltyvAwIZq?usp=sharing (note that Google Colab runs on py3.10).

As a follow-up, can you share the output of the pip list?

XariZaru commented 8 months ago

hey @XariZaru, are you sure Chroma is installed? I've tested with your setup and the latest version of Langchain; it appears to be working. Here's a colab notebook I've tested with https://colab.research.google.com/drive/1V6mhBOqCn6WonhnDKnAfP8lltyvAwIZq?usp=sharing (note that Google Colab runs on py3.10).

As a follow-up, can you share the output of the pip list?

I'm sorry, I'm not sure what you mean by pip list. What list are we referring to?

tazarov commented 8 months ago

@XariZaru, to verify that you have the latest Chroma and its dependencies installed.

XariZaru commented 8 months ago

What I did was the following:

import chromadb
import langchain

print("ChromaDB", chromadb.__version__)
print("LangChain", langchain.__version__)

This is the result:

ChromaDB 0.4.22
LangChain 0.0.354