2

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,
        )

1 Answers1

0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 19 '23 at 04:03