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)
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,
)
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,
)
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With