summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2024-05-12 12:53:53 +0200
committerGitHub <noreply@github.com>2024-05-12 12:53:53 +0200
commit894929122170b815a0b091a646db07693c92144d (patch)
treed606e708228618be566c513f3cf2ebef73538af3 /pkgs
parentbaabb6ca8ca8dd424578a43862f8756368265ece (diff)
parentaff1950a3f9f24f2dac1944f0d962353bd044303 (diff)
Merge pull request #305586 from drupol/private-gpt/init
private-gpt: init at 0.5.0
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/pr/private-gpt/package.nix17
-rw-r--r--pkgs/development/python-modules/private-gpt/default.nix119
-rw-r--r--pkgs/top-level/python-packages.nix2
3 files changed, 138 insertions, 0 deletions
diff --git a/pkgs/by-name/pr/private-gpt/package.nix b/pkgs/by-name/pr/private-gpt/package.nix
new file mode 100644
index 000000000000..1b717cc2bfb8
--- /dev/null
+++ b/pkgs/by-name/pr/private-gpt/package.nix
@@ -0,0 +1,17 @@
+{ python3Packages
+, makeBinaryWrapper
+}:
+
+python3Packages.toPythonApplication (python3Packages.private-gpt.overrideAttrs (oldAttrs: {
+ nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ makeBinaryWrapper ];
+
+ passthru.cl100k_base = {
+ inherit (python3Packages.private-gpt.cl100k_base) tiktoken;
+ };
+
+ postInstall = ''
+ makeWrapper ${python3Packages.python.interpreter} $out/bin/private-gpt \
+ --prefix PYTHONPATH : "$PYTHONPATH" \
+ --add-flags "-m private_gpt"
+ '';
+}))
diff --git a/pkgs/development/python-modules/private-gpt/default.nix b/pkgs/development/python-modules/private-gpt/default.nix
new file mode 100644
index 000000000000..226489d046cb
--- /dev/null
+++ b/pkgs/development/python-modules/private-gpt/default.nix
@@ -0,0 +1,119 @@
+{ lib
+, buildPythonPackage
+, python
+, fetchFromGitHub
+, poetry-core
+, fastapi
+, injector
+, llama-index-core
+, llama-index-readers-file
+, huggingface-hub
+, python-multipart
+, pyyaml
+, transformers
+, uvicorn
+, watchdog
+, gradio
+, fetchurl
+, fetchpatch
+}:
+
+buildPythonPackage rec {
+ pname = "private-gpt";
+ version = "0.5.0";
+ pyproject = true;
+
+ src = fetchFromGitHub {
+ owner = "zylon-ai";
+ repo = "private-gpt";
+ rev = "v${version}";
+ hash = "sha256-bjydzJhOJjmbflcJbuMyNsmby7HtNPFW3MY2Tw12cHw=";
+ };
+
+ patches = [
+ # Fix a vulnerability, to be removed in the next bump version
+ # See https://github.com/zylon-ai/private-gpt/pull/1890
+ (fetchpatch {
+ url = "https://github.com/zylon-ai/private-gpt/commit/86368c61760c9cee5d977131d23ad2a3e063cbe9.patch";
+ hash = "sha256-4ysRUuNaHW4bmNzg4fn++89b430LP6AzYDoX2HplVH0=";
+ })
+ ];
+
+ build-system = [
+ poetry-core
+ ];
+
+ dependencies = [
+ fastapi
+ injector
+ llama-index-core
+ llama-index-readers-file
+ python-multipart
+ pyyaml
+ transformers
+ uvicorn
+ watchdog
+ ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
+
+ # This is needed for running the tests and the service in offline mode,
+ # See related issue at https://github.com/zylon-ai/private-gpt/issues/1870
+ passthru.cl100k_base.tiktoken = fetchurl {
+ url = "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken";
+ hash = "sha256-Ijkht27pm96ZW3/3OFE+7xAPtR0YyTWXoRO8/+hlsqc=";
+ };
+
+ passthru.optional-dependencies = with python.pkgs; {
+ embeddings-huggingface = [
+ huggingface-hub
+ llama-index-embeddings-huggingface
+ ];
+ embeddings-ollama = [
+ llama-index-embeddings-ollama
+ ];
+ embeddings-openai = [
+ llama-index-embeddings-openai
+ ];
+ embeddings-sagemaker = [
+ boto3
+ ];
+ llms-ollama = [
+ llama-index-llms-ollama
+ ];
+ llms-openai = [
+ llama-index-llms-openai
+ ];
+ llms-openai-like = [
+ llama-index-llms-openai-like
+ ];
+ llms-sagemaker = [
+ boto3
+ ];
+ ui = [
+ gradio
+ ];
+ vector-stores-chroma = [
+ llama-index-vector-stores-chroma
+ ];
+ vector-stores-postgres = [
+ llama-index-vector-stores-postgres
+ ];
+ vector-stores-qdrant = [
+ llama-index-vector-stores-qdrant
+ ];
+ };
+
+ postInstall = ''
+ cp settings*.yaml $out/${python.sitePackages}/private_gpt/
+ '';
+
+ pythonImportsCheck = [ "private_gpt" ];
+
+ meta = {
+ changelog = "https://github.com/zylon-ai/private-gpt/blob/${src.rev}/CHANGELOG.md";
+ description = "Interact with your documents using the power of GPT, 100% privately, no data leaks";
+ homepage = "https://github.com/zylon-ai/private-gpt";
+ license = lib.licenses.asl20;
+ mainProgram = "private-gpt";
+ maintainers = with lib.maintainers; [ drupol ];
+ };
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 180c167c1f82..80e540400ada 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -9891,6 +9891,8 @@ self: super: with self; {
ppdeep = callPackage ../development/python-modules/ppdeep { };
+ private-gpt = callPackage ../development/python-modules/private-gpt { };
+
prodict = callPackage ../development/python-modules/prodict { };
prometheus-pandas = callPackage ../development/python-modules/prometheus-pandas { };