summary refs log tree commit diff
path: root/pkgs/development/python-modules/tokentrim/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/tokentrim/default.nix')
-rw-r--r--pkgs/development/python-modules/tokentrim/default.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/tokentrim/default.nix b/pkgs/development/python-modules/tokentrim/default.nix
new file mode 100644
index 00000000000..c830d29b8a9
--- /dev/null
+++ b/pkgs/development/python-modules/tokentrim/default.nix
@@ -0,0 +1,39 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, poetry-core
+, tiktoken
+}:
+
+buildPythonPackage {
+  pname = "tokentrim";
+  version = "unstable-2023-09-07";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "KillianLucas";
+    repo = "tokentrim";
+    rev = "e98ad3a2ca0e321a7347f76c30be584175495139";
+    hash = "sha256-95xitHnbFFaj0xPuLMWvIvuJzoCO3VSd592X1RI9h3A=";
+  };
+
+  nativeBuildInputs = [
+    poetry-core
+  ];
+
+  propagatedBuildInputs = [
+    tiktoken
+  ];
+
+  pythonImportsCheck = [ "tokentrim" ];
+
+  # tests connect to openai
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Easily trim 'messages' arrays for use with GPTs";
+    homepage = "https://github.com/KillianLucas/tokentrim";
+    license = licenses.mit;
+    maintainers = with maintainers; [ happysalada ];
+  };
+}