nix: support Python tokenizer conversion in the router (#2515)

Ideally we wouldn't have the router wrapper that this change adds,
but when I give PyO3 a Python interpreter with packages, it ends
up linking libpython from the Python interpreter rather than the
constructed environment and cannot pick up the Python modules as
a result.
This commit is contained in:
Daniël de Kok 2024-09-12 10:44:01 +02:00 committed by GitHub
parent 69e3be20fb
commit 94304649f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 3 deletions

View File

@ -46,9 +46,26 @@
launcher = cargoNix.workspaceMembers.text-generation-launcher.build.override { launcher = cargoNix.workspaceMembers.text-generation-launcher.build.override {
inherit crateOverrides; inherit crateOverrides;
}; };
router = cargoNix.workspaceMembers.text-generation-router-v3.build.override { router =
let
routerUnwrapped = cargoNix.workspaceMembers.text-generation-router-v3.build.override {
inherit crateOverrides; inherit crateOverrides;
}; };
packagePath =
with pkgs.python3.pkgs;
makePythonPath [
protobuf
sentencepiece
torch
transformers
];
in
pkgs.writeShellApplication {
name = "text-generation-router";
text = ''
PYTHONPATH="${packagePath}" ${routerUnwrapped}/bin/text-generation-router "$@"
'';
};
server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; }; server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; };
in in
{ {

View File

@ -28,6 +28,9 @@ defaultCrateOverrides
]; ];
}; };
}; };
pyo3-build-config = attrs: {
buildInputs = [ python3 ];
};
text-generation-benchmark = attrs: { text-generation-benchmark = attrs: {
src = filter { src = filter {
root = ../benchmark; root = ../benchmark;