Stuck with incompatible langchain/openai packages for Jupyter AI

Dear all,
I am stuck after several hours of installing and uninstalling langchain packages to try and make Jupyter AI work on a new work machine (Mac M1 macOS Sonoma 14.4.1). Can anyone help?

I’ve gone back and forth from having a broken Juypyter AI extension with the red-background message of “There seems to be a problem with the Chat backend, please look at the JupyterLab server logs or contact your administrator to correct this problem” to having the extension work but not seeing the Open AI models. The latter is my state now.

I just cannot get the right combination of versions, and am at the end of my rope. This from conda list right now:

jupyter-ai                2.24.0             pyhd8ed1ab_0    conda-forge
jupyter-ai-magics         2.24.0             pyhd8ed1ab_0    conda-forge
jupyterlab                4.2.5           py311hca03da5_0 
langchain                 0.2.16             pyhd8ed1ab_0    conda-forge
langchain-community       0.0.34                   pypi_0    pypi
langchain-core            0.2.41                   pypi_0    pypi
langchain-openai          0.2.1                    pypi_0    pypi
langchain-text-splitters  0.2.4              pyhd8ed1ab_0    conda-forge
langsmith                 0.1.129            pyhd8ed1ab_0    conda-forge
openai                    1.50.2                   pypi_0    pypi

When starting Jupyter Lab, I see the following error message:

Unable to load embeddings model provider class from entry point openai: cannot pickle ‘classmethod’ object.

I’m so stuck! Your help is appreciated mightily :pray:

Hi,

TL/DR: I found a workaround, but I’m unsure what the proper fix is. Run pip install jupyter-ai && pip install lanchain-openai===0.1.25 and it should restore functionality, with openai model selection enabled and working.

I ran into the same issue, looks the langchain-openai pip package (>=0.2.*) was incompatbile with langchain-core in my env, which in turn breaks jupyter-ai.

Installing collected packages: langchain-core
  Attempting uninstall: langchain-core
    Found existing installation: langchain-core 0.3.9
    Uninstalling langchain-core-0.3.9:
      Successfully uninstalled langchain-core-0.3.9
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
langchain-openai 0.2.2 requires langchain-core<0.4.0,>=0.3.9, but you have langchain-core 0.2.41 which is incompatible.
Successfully installed langchain-core-0.2.41

Rolling back to the most recent 0.1.* release of lanchain-openai fixes it, and enabled openai model selection in chat UI settings. I confirmed it works with gpt4o (using jupyterLab 4.2.5 on MacOS)

I’m relatively new to python so I’m unsure what is going on; my guess is that jupyter-ai packages may need to be updated to be version aligned to langchain deps.

HTH.

1 Like

Thank you, @satlus — this worked for me now and you have made my day!!!

1 Like