jupyter-ai icon indicating copy to clipboard operation
jupyter-ai copied to clipboard

Error when trying to use huggingface models with older version of `huggingface-hub`

Open krassowski opened this issue 1 year ago • 1 comments
trafficstars

Description

https://github.com/jupyterlab/jupyter-ai/pull/784 was released yesterday but it does not work out of the box on existing installations. When trying to get a reply I get:

[E 2024-05-22 10:26:26.680 AiExtension] InferenceClient.post() got an unexpected keyword argument 'stream'

I would wager that this is because a specific version of huggingface_hub is needed, but there is no pin on version as of now: huggingface_hub

https://github.com/jupyterlab/jupyter-ai/blob/465d9913d8f6679dcf79c4f6d9111b18daac08b9/packages/jupyter-ai-magics/pyproject.toml#L41

Reproduce

huggingface-hub               0.15.1
jupyter_ai                    2.16.0

Upgrading huggingface-hub to 0.23.1 fixes the problem.

Expected behavior

  • Version pin is added so that installs get the new version installed
  • Maybe a version warning is shown if the dependency version is too old? Not sure.

krassowski avatar May 22 '24 09:05 krassowski

@krassowski Thank you for documenting this! The huggingface_hub dependency is listed in the [all] optional dependency group, as we keep all of our model provider dependencies optional to minimize conflicts with a user's environment.

To install & upgrade all optional dependencies, you should be able to run:

pip install -U "jupyter_ai[all]"

I agree that we should both 1) add version ranges to each provider's declared dependencies, and 2) somehow check in the backend both a) whether the package is installed, and b) whether the package meets the version range, if specified.

2.a) is tracked in #680. Most ImportErrors raised by LangChain are caught and returned as an error message in the chat, but there seem to be edge cases that require further investigation. 1) and 2.b) are not implemented. I had explored this route, but ran into difficulties reliably getting the version of a package.

dlqqq avatar May 31 '24 18:05 dlqqq