Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'chromadb' has no attribute 'config'

so i recently started to work on chromabd and i am facing this error: "module 'chromadb' has no attribute 'config'"

here is my code:

    from langchain.vectorstores import Chroma 
    from sentence_transformers import SentenceTransformer

    model = SentenceTransformer('all-MiniLM-L6-v2')

    #Sentences are encoded by calling model.encode()
    embeddings = [model.encode(text[i].page_content) for i in range(len(text))]

    presist_directory = 'db'
    vectordb =       Chroma.from_documents(documents=text,embedding=embeddings,persist_directory=presist_directory)
  1. i have already tried down versioning chromadb
  2. tried this solution:
    from langchain.indexes import VectorstoreIndexCreator
    from langchain.vectorstores import Chroma

    presist_directory = 'db'
    vectordb = VectorstoreIndexCreator().from_documents(
        documents=text,
        embedding=embeddings,
        persist_directory=presist_directory,
        vectorstore_cls=Chroma,
    ) 
  1. and tried this solution too:
    import chromadb

    # Get the version of ChromaDB
    chroma_version = chromadb.__version__

    # Check if the version is 0.4 or later
    if float(chroma_version[:3]) >= 0.4:
        # Use the new configuration
        _client_settings = chromadb.config.Settings(
            chroma_db_impl="new_configuration",
            persist_directory=persist_directory,
        )
    else:
        # Use the old configuration
        _client_settings = chromadb.config.Settings(
            chroma_db_impl="duckdb+parquet",
            persist_directory=persist_directory,
        )

like image 867
Fahad Ali Yousaf Avatar asked Jul 27 '26 01:07

Fahad Ali Yousaf


2 Answers

This happens when you import chromadb and THEN mess with the sqlite module like below

__import__('pysqlite3')
import pysqlite3
sys.modules['sqlite3'] = sys.modules["pysqlite3"]

Just restart the kernel (if you are in jupyter) and make sure you import chromadb AFTER tinkering with sys.modules

like image 192
Abbas Gadhia Avatar answered Jul 28 '26 16:07

Abbas Gadhia


i got the solution, chromadb have compatibility issues. In my case i have to downgrade the version from 0.4.6 to 0.4.0 . in 0.3.26 it throw an error of 'Collection' object has no attribute 'upsert' and the updated version throw this error. so version 0.4.0 seems to work for me

like image 38
Fahad Ali Yousaf Avatar answered Jul 28 '26 14:07

Fahad Ali Yousaf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!