chroma
chroma copied to clipboard
Index not found after using it
I used chromadb to embed and index some data, but randomly after being used, I started getting Index not found :
WARNING:root:Collection langchain already exists, Do you have the right embedding function?
DEBUG:Chroma:Index not found
while it was there and everything was working smoothly, i also checked the persistent directory, the 'chroma-embeddings.parquet' file size changed to 17X bytes
@aymanestr can you share more code and/or a repro?
These are the two snipets i'm using to do the Q/A and the embedding :
def get_answer(folder, query: str) -> Dict[str, Any]:
# Get the answer
embeddings = OpenAIEmbeddings()
db=Chroma(persist_directory=folder, embedding_function=embeddings)
count = db._collection.count()
chain_type_kwargs = {"prompt": PROMPT}
if count < 4:
qa = VectorDBQA.from_chain_type(llm=OpenAI(temperature=0.5) , chain_type="stuff", k=count, vectorstore=db, return_source_documents=True, chain_type_kwargs=chain_type_kwargs)
answer = qa(query)
print(answer)
else:
qa = VectorDBQA.from_chain_type(llm=OpenAI(temperature=0.5) , chain_type="stuff", vectorstore=db, return_source_documents=True, chain_type_kwargs=chain_type_kwargs)
answer = qa(query)
return answer
def embed_docs(docs ,docname: str, user_id: str):
"""Embeds a list of Documents and returns a Chromadb index"""
try:
doc_id = uuid.uuid4()
persist_directory = doc_id
fold = os.path.join(os.getcwd(), persist_directory)
if not os.path.exists(fold):
os.makedirs(fold)
embeddings = OpenAIEmbeddings()
db = Chroma.from_documents(docs, embeddings, persist_directory=persist_directory)
return persist_directory
except Exception as e:
print(e)
DEBUG:Chroma:Index not found
DEBUG:Chroma:Index saved to {self._save_folder}/index.bin
DEBUG:Chroma:Index saved to {self._save_folder}/index.bin
@aymanestr were you able to resolve this? closing this for now but happy to re-open