chroma-core / chroma

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

[Bug]: sqlite3.OperationalError: no such column: collections.topic #2144

Open pseudotensor opened 6 months ago

pseudotensor commented 6 months ago

What happened?


  File "/home/tomershm/h2ogpt/src/gpt_langchain.py", line 4519, in get_existing_db
    db = chroma_class(persist_directory=persist_directory, embedding_function=embedding,
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/langchain_community/vectorstores/chroma.py", line 126, in __init__
    self._collection = self._client.get_or_create_collection(
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/api/client.py", line 237, in get_or_create_collection
    return self._server.get_or_create_collection(
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/api/segment.py", line 217, in get_or_create_collection
    return self.create_collection(  # type: ignore
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/api/segment.py", line 167, in create_collection
    coll, created = self._sysdb.create_collection(
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/db/mixins/sysdb.py", line 209, in create_collection
    existing = self.get_collections(name=name, tenant=tenant, database=database)
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 127, in wrapper
    return f(*args, **kwargs)
  File "/home/tomershm/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/chromadb/db/mixins/sysdb.py", line 435, in get_collections
    rows = cur.execute(sql, params).fetchall()
sqlite3.OperationalError: no such column: collections.topic

Versions

chroma 0.4.23 python 3.10.

A user of h2oGPT hit this, unsure why. Any ideas?

Relevant log output

No response

MathiasToftas commented 6 months ago

I've also encountered this issue today when running a a script that worked the week before last.

I did some looking around at commits and I think I found the problem. The third party tool you are using is likely using an older version of chroma (something like 0.4.x) because the topic column was removed in the latest version of chroma 0.5.0 (see https://github.com/chroma-core/chroma/pull/1933)

So if you have a version mismatch (say a new instance of chromadb and an older script/tool using it) you will get this error

tazarov commented 6 months ago

@pseudotensor, in 0.4.24, we phased out a column in the SQLite DB. The change is not backward compatible for clients. That means that if you have a DB created or accessed with 0.4.24, we apply a migration to the chroma.sqlite3 file, which is non-reversible, and any older client will give you the above exception.

HammadB commented 6 months ago

I think this is due to a version mismatch with 0.5. Can you confirm if that solves your issue ?

aliyassine26 commented 6 months ago

switching to 0.5 solves the issue

UPDATE: now I am facing this error when using collection.query

chromadb Exception: {"error":"AttributeError(\"type object 'QueryEmbedding' has no attribute 'model_validate'\")"}

tazarov commented 6 months ago

@aliyassine26, this is due to an older version of pydantic. Can you bump your pydantic version to 2.x+

Sayantanighosh17github commented 6 months ago

I have a Chroma version: 0.4.22 , SQLite version: 3.42.0 , Python 3.11.9 still getting the issue Exception has occurred: OperationalError no such column: collections.topic File "C:\Users\SayantaniGhosh\Documents\IBM24\GenAI_WatsonX_Usecase_DIAGEO\git_repo\test_bpmn_fiori\services\test1.py", line 34, in fetch_all_docs db3 = Chroma(persist_directory="./db_manager/chroma_db_impact", embedding_function=embeddings1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\SayantaniGhosh\Documents\IBM24\GenAI_WatsonX_Usecase_DIAGEO\git_repo\test_bpmn_fiori\services\test1.py", line 54, in extracted_details_for_fiori_app = fetch_all_docs(fiori_app_names_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sqlite3.OperationalError: no such column: collections.topic

tazarov commented 6 months ago

@Sayantanighosh17github, this issue appears when you have accessed your Chroma persistent data with 0.5.0 version. Chroma does a schema migration from 0.4.x->0.5.x. To resolve start using Chroma 0.5.0.

Princekrampah commented 3 months ago

Thanks you guys so much!