Skip to content

Instantly share code, notes, and snippets.

@olebedev
Last active September 18, 2024 23:22
Show Gist options
  • Save olebedev/b87f1f573be817530f2254b43ea936dc to your computer and use it in GitHub Desktop.
Save olebedev/b87f1f573be817530f2254b43ea936dc to your computer and use it in GitHub Desktop.
LLM CLI in Nix

Installation

nix-env -i -f ./default.nix
with import
(fetchTarball "https://github.com/NixOS/nixpkgs/archive/8f75dd40856dc79cd07f92270ae3f64a1f4b9de2.tar.gz")
{ };
# Update LLM package to version 0.16 with o1-preview support.
# https://github.com/NixOS/nixpkgs/commit/8f75dd40856dc79cd07f92270ae3f64a1f4b9de2
let
llmClaude3 = python3Packages.callPackage ./llm-claude-3.nix { };
pyWithPackages = (python3.withPackages (py: [
py.llm
llmClaude3
]));
in
runCommand "llm" { } ''
mkdir -p $out/bin
ln -s ${pyWithPackages}/bin/llm $out/bin/llm
''
{ lib
, buildPythonPackage
, fetchPypi
, pythonOlder
, requests
, pydantic
, typing-extensions
, anthropic
, poetry-core
, flit-core
, setuptools
, llm
}:
let
llm-claude = buildPythonPackage rec {
pname = "llm-claude";
version = "0.4.0"; # Update this to the latest version
format = "pyproject";
buildInputs = [
setuptools
poetry-core
flit-core
llm
];
POETRY_CORE = "${poetry-core}/lib/python3.9/site-packages/poetry/core";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-VyLWJoPKQDuirQ/iDDNYCvo/tbWSVqx3DkTbMTU4X2w=";
};
propagatedBuildInputs = [
anthropic
];
# Add any necessary build inputs or test inputs
pythonImportsCheck = [ "llm_claude" ];
meta = with lib; {
description = "Claude plugin for LLM";
homepage = "https://github.com/simonw/llm-claude";
# license = licenses.apache20;
};
};
in
buildPythonPackage rec {
pname = "llm_claude_3";
version = "0.4"; # Replace with the actual version
format = "pyproject";
buildInputs = [
setuptools
poetry-core
flit-core
llm
];
POETRY_CORE = "${poetry-core}/lib/python3.9/site-packages/poetry/core";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-d12EcFJZIwWRNG3llRlKWLB2vBBnN//7+GYo3tFI3dk="; # Replace with the actual SHA256 hash
};
propagatedBuildInputs = [
anthropic
llm-claude
];
# If there are any build-time dependencies, add them here
# buildInputs = [ ];
# If there are any test dependencies, add them here
# checkInputs = [ ];
# Disable tests if they're not available or if they're failing
doCheck = false;
pythonImportsCheck = [ "llm_claude_3" ];
meta = with lib; {
description = "Claude 3 plugin for LLM";
homepage = "https://pypi.org/project/llm-claude-3/";
license = licenses.mit; # Replace with the actual license
maintainers = with maintainers; [ ]; # Add maintainers if applicable
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment