nixpkgs/pkgs/development/python-modules/llm/001-disable-install-uninstall-commands.patch
Philip Taron b06e408d0d llm: customize the message on llm install and llm uninstall with the list of plugins possible
This way, users know what they can specify as far as plugins go. It serves as a plugin directory.
2025-05-31 20:22:54 -07:00

56 lines
1.5 KiB
Diff

diff --git i/llm/cli.py w/llm/cli.py
index 09e4e2d..8424a5e 100644
--- i/llm/cli.py
+++ w/llm/cli.py
@@ -2383,18 +2383,18 @@ def display_truncated(text):
)
def install(packages, upgrade, editable, force_reinstall, no_cache_dir):
"""Install packages from PyPI into the same environment as LLM"""
- args = ["pip", "install"]
- if upgrade:
- args += ["--upgrade"]
- if editable:
- args += ["--editable", editable]
- if force_reinstall:
- args += ["--force-reinstall"]
- if no_cache_dir:
- args += ["--no-cache-dir"]
- args += list(packages)
- sys.argv = args
- run_module("pip", run_name="__main__")
+ click.echo(
+"""Install command has been disabled for Nix. To install extra `llm` plugins, use the `llm.withPlugins` function.
+
+Example:
+
+```nix
+llm.withPlugins {
+ @listOfPackagedPlugins@
+}
+```
+"""
+ )
@cli.command()
@@ -2402,8 +2402,18 @@ def install(packages, upgrade, editable, force_reinstall, no_cache_dir):
@click.option("-y", "--yes", is_flag=True, help="Don't ask for confirmation")
def uninstall(packages, yes):
"""Uninstall Python packages from the LLM environment"""
- sys.argv = ["pip", "uninstall"] + list(packages) + (["-y"] if yes else [])
- run_module("pip", run_name="__main__")
+ click.echo(
+"""Uninstall command has been disabled for Nix. To remove `llm` plugins, use the `llm.withPlugins` function with the desired set of plugins specified.
+
+Example:
+
+```nix
+llm.withPlugins {
+ @listOfPackagedPlugins@
+}
+```
+"""
+ )
@cli.command()