2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonApplication,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
makeWrapper,
|
|
|
|
pytestCheckHook,
|
2024-07-27 06:49:29 +00:00
|
|
|
python,
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonOlder,
|
|
|
|
ruff,
|
|
|
|
setuptools,
|
2024-07-27 06:49:29 +00:00
|
|
|
click-default-group,
|
|
|
|
numpy,
|
|
|
|
openai,
|
|
|
|
pip,
|
|
|
|
pluggy,
|
|
|
|
pydantic,
|
|
|
|
python-ulid,
|
|
|
|
pyyaml,
|
|
|
|
sqlite-migrate,
|
|
|
|
cogapp,
|
|
|
|
pytest-httpx,
|
|
|
|
sqlite-utils,
|
2024-02-29 20:09:43 +00:00
|
|
|
}:
|
|
|
|
let
|
2024-01-02 11:29:13 +00:00
|
|
|
llm = buildPythonPackage rec {
|
|
|
|
pname = "llm";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "0.14";
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.8";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "simonw";
|
2024-02-29 20:09:43 +00:00
|
|
|
repo = "llm";
|
2024-01-02 11:29:13 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-CgGVFUsntVkF0zORAtYQQMAeGtIwBbj9hE0Ei1OCGq4=";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
patches = [ ./001-disable-install-uninstall-commands.patch ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ setuptools ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
propagatedBuildInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
click-default-group
|
|
|
|
numpy
|
|
|
|
openai
|
2024-02-29 20:09:43 +00:00
|
|
|
pip
|
2024-01-02 11:29:13 +00:00
|
|
|
pluggy
|
|
|
|
pydantic
|
|
|
|
python-ulid
|
|
|
|
pyyaml
|
|
|
|
setuptools # for pkg_resources
|
|
|
|
sqlite-migrate
|
|
|
|
sqlite-utils
|
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
nativeCheckInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
cogapp
|
|
|
|
numpy
|
2024-02-29 20:09:43 +00:00
|
|
|
pytest-httpx
|
2024-01-02 11:29:13 +00:00
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"-svv"
|
|
|
|
"tests/"
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "llm" ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
passthru = {
|
|
|
|
inherit withPlugins;
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/simonw/llm";
|
|
|
|
description = "Access large language models from the command-line";
|
|
|
|
changelog = "https://github.com/simonw/llm/releases/tag/${version}";
|
|
|
|
license = licenses.asl20;
|
|
|
|
mainProgram = "llm";
|
2024-06-05 15:53:02 +00:00
|
|
|
maintainers = with maintainers; [ aldoborrero ];
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
withPlugins =
|
|
|
|
plugins:
|
|
|
|
buildPythonApplication {
|
|
|
|
inherit (llm) pname version;
|
|
|
|
format = "other";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabled = pythonOlder "3.8";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
dontUnpack = true;
|
|
|
|
dontBuild = true;
|
|
|
|
doCheck = false;
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
installPhase = ''
|
|
|
|
makeWrapper ${llm}/bin/llm $out/bin/llm \
|
2024-07-27 06:49:29 +00:00
|
|
|
--prefix PYTHONPATH : "${llm}/${python.sitePackages}:$PYTHONPATH"
|
2024-06-05 15:53:02 +00:00
|
|
|
ln -sfv ${llm}/lib $out/lib
|
|
|
|
'';
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs = llm.propagatedBuildInputs ++ plugins;
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
passthru = llm.passthru // {
|
|
|
|
withPlugins = morePlugins: withPlugins (morePlugins ++ plugins);
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
inherit (llm) meta;
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
in
|
2024-06-05 15:53:02 +00:00
|
|
|
llm
|