crate / cratedb-examples

A collection of clear and concise examples how to work with CrateDB.
Apache License 2.0
9 stars 7 forks source link

ML/LLM: `cratedb_rag_customer_support_langchain.ipynb` croaks with `ImportError: cannot import name 'patch_inspector' from 'cratedb_toolkit.sqlalchemy.patch'` #480

Closed amotl closed 3 months ago

amotl commented 3 months ago

@wierdvanderhaar reported another problem. Thank you.

WARNING: langchain 0.2.3 does not provide the extra 'cratedb'
WARNING: langchain 0.2.3 does not provide the extra 'openai'

ImportError                               Traceback (most recent call last)
<ipython-input-2-451439e6f556> in <cell line: 11>()
      9 from langchain_openai import OpenAIEmbeddings
     10 from langchain_community.document_loaders import CSVLoader
---> 11 from langchain_community.vectorstores import CrateDBVectorSearch
     12 
     13 warnings.filterwarnings('ignore')

3 frames
/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/cratedb/base.py in <module>
     15 
     16 import sqlalchemy
---> 17 from cratedb_toolkit.sqlalchemy.patch import patch_inspector
     18 from cratedb_toolkit.sqlalchemy.polyfill import (
     19     refresh_table,

ImportError: cannot import name 'patch_inspector' from 'cratedb_toolkit.sqlalchemy.patch' (/usr/local/lib/python3.10/dist-packages/cratedb_toolkit/sqlalchemy/patch.py)
amotl commented 3 months ago

Apparent quick fix:

pip install cratedb-toolkit==0.0.12

Applied with ef3c38df94.

amotl commented 3 months ago

Another improvement: ff48b76f584.

amotl commented 3 months ago

Apparently, it worked only on Google Colab. On CI, installing cratedb-toolkit 0.0.12 clearly shows it is not compatible.

-- https://github.com/crate/cratedb-examples/actions/runs/9565093245/job/26367271413?pr=482#step:6:480

amotl commented 3 months ago

@wierdvanderhaar: I will drop ef3c38df94 from GH-482 again, and would like to ask you to re-validate your environment, possibly wiping it completely. If the error still persists, it must be something special about Google Colab again, most probably in the area of dependency hell, and we need to investigate more closer.

amotl commented 3 months ago
ImportError: cannot import name 'patch_inspector' from 'cratedb_toolkit.sqlalchemy.patch'

Now also on CI: https://github.com/crate/cratedb-examples/actions/runs/9565423703/job/26368328266?pr=482#step:6:803

Excellent, there must be a dependency hiccup then, which can deterministically be fixed.

amotl commented 3 months ago

Fixed by downgrading to cratedb-toolkit==0.0.13.