simonw/llm

llm loses track of plugins when upgraded (with uv)

Opened this issue · 1 comments

This may not be an llm issue, but could have to do with the interaction of the plugin mechanism with python packaging tooling.

I have llm installed (on MacOS) via uv tool install llm. When I update llm with uv tool upgrade llm, it forgets about all of its installed plugins:

~ > llm plugins                                                                                                                                                                                                                                                                                                                                          
[
  {
    "name": "llm-claude-3",
    "hooks": [
      "register_models"
    ],
    "version": "0.4.1"
  },
  {
    "name": "llm-llamafile",
    "hooks": [
      "register_models"
    ],
    "version": "0.1"
  },
  {
    "name": "llm-perplexity",
    "hooks": [
      "register_models"
    ],
    "version": "0.9"
  },
  {
    "name": "llm-ollama",
    "hooks": [
      "register_commands",
      "register_models"
    ],
    "version": "0.5.0"
  },
  {
    "name": "llm-cmd",
    "hooks": [
      "register_commands"
    ],
    "version": "0.2a0"
  },
  {
    "name": "llm-claude",
    "hooks": [
      "register_models"
    ],
    "version": "0.4.0"
  },
  {
    "name": "llm-mistral",
    "hooks": [
      "register_commands",
      "register_embedding_models",
      "register_models"
    ],
    "version": "0.5"
  }
]

Now I update:

~ > uv tool upgrade llm                                                                                                                                                                                                                                                                                                                                   
Modified llm environment
 - anthropic==0.34.2
 - charset-normalizer==3.3.2
 - filelock==3.16.0
 - fsspec==2024.9.0
 - httpx-sse==0.4.0
 - huggingface-hub==0.24.7
 - llm-claude==0.4.0
 - llm-claude-3==0.4.1
 - llm-cmd==0.2a0
 - llm-llamafile==0.1
 - llm-mistral==0.5
 - llm-ollama==0.5.0
 - llm-perplexity==0.9
 - ollama==0.3.3
 - packaging==24.1
 - prompt-toolkit==3.0.47
 - pygments==2.18.0
 - requests==2.32.3
 - tokenizers==0.20.0
 - urllib3==2.2.3
 - wcwidth==0.2.13

Now, no more plugins

~ > llm plugins                                                                                                                                                                                                                                                                                                                                           
[]

Having saved the JSON of plugins, I can re-install them, and it appears that everything is installed from the cache. Is this because llm install is using pip or something similar, and uv handles things differently?

tspng commented

You are right, llm installs plugins with pip into the same environment it runs in. uv does not know about these dependencies and will remove them when upgrading the llm package.

A workaround is to install llm plugins as additional Python dependencies with uv tool install --extra <llm-plugin> llm, as documented here.
One caveat though, you cannot add additional dependencies this way. You always have to provide the full list of extra dependencies with multiple --extra options.

EDIT: fix uv tool install command