From 5f69f0ed2eb1751e24e0cb7f4100bd973dd2db69 Mon Sep 17 00:00:00 2001 From: happysalada Date: Sat, 2 Dec 2023 08:49:11 +0900 Subject: [PATCH] python311Packages.openai: 0.28.1 -> 1.3.7 openai: cleanup --- .../python-modules/openai/default.nix | 74 +++++++++---------- pkgs/top-level/all-packages.nix | 4 - 2 files changed, 33 insertions(+), 45 deletions(-) diff --git a/pkgs/development/python-modules/openai/default.nix b/pkgs/development/python-modules/openai/default.nix index 89a02ae69f15..3c13e035bf02 100644 --- a/pkgs/development/python-modules/openai/default.nix +++ b/pkgs/development/python-modules/openai/default.nix @@ -1,30 +1,32 @@ { lib , buildPythonPackage , fetchFromGitHub -, aiohttp -, matplotlib +, pythonOlder +, hatchling +# propagated +, httpx +, pydantic +, typing-extensions +, anyio +, distro +, sniffio +, tqdm +# optional , numpy -, openpyxl , pandas , pandas-stubs -, plotly +# tests +, pytestCheckHook , pytest-asyncio , pytest-mock -, pytestCheckHook -, pythonOlder -, requests -, scikit-learn -, tenacity -, tqdm -, typing-extensions -, wandb -, withOptionalDependencies ? false +, respx +, dirty-equals }: buildPythonPackage rec { pname = "openai"; - version = "0.28.1"; - format = "setuptools"; + version = "1.3.7"; + pyproject = true; disabled = pythonOlder "3.7.1"; @@ -32,35 +34,30 @@ buildPythonPackage rec { owner = "openai"; repo = "openai-python"; rev = "refs/tags/v${version}"; - hash = "sha256-liJyeGxnYIC/jUQKdeATHpVJb/12KGbeM94Y2YQphfY="; + hash = "sha256-Pa53s3U5vby1Fq14WMCJnSR6KA3xkVHmBexkNoX/0sk="; }; + nativeBuildInputs = [ + hatchling + ]; + propagatedBuildInputs = [ - aiohttp - requests + httpx + pydantic + anyio + distro + sniffio tqdm ] ++ lib.optionals (pythonOlder "3.8") [ typing-extensions - ] ++ lib.optionals withOptionalDependencies (builtins.attrValues { - inherit (passthru.optional-dependencies) embeddings wandb; - }); + ]; passthru.optional-dependencies = { datalib = [ numpy - openpyxl pandas pandas-stubs ]; - embeddings = [ - matplotlib - plotly - scikit-learn - tenacity - ] ++ passthru.optional-dependencies.datalib; - wandb = [ - wandb - ] ++ passthru.optional-dependencies.datalib; }; pythonImportsCheck = [ @@ -71,21 +68,16 @@ buildPythonPackage rec { pytestCheckHook pytest-asyncio pytest-mock - ]; - - pytestFlagsArray = [ - "openai/tests" + respx + dirty-equals ]; OPENAI_API_KEY = "sk-foo"; disabledTestPaths = [ - # Requires a real API key - "openai/tests/test_endpoints.py" - "openai/tests/asyncio/test_endpoints.py" - # openai: command not found - "openai/tests/test_file_cli.py" - "openai/tests/test_long_examples_validator.py" + # makes network requests + "tests/test_client.py" + "tests/api_resources" ]; meta = with lib; { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a35ec0b9d1b3..0ed33bbeef96 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19711,10 +19711,6 @@ with pkgs; openai = with python3Packages; toPythonApplication openai; - openai-full = with python3Packages; toPythonApplication (openai.override { - withOptionalDependencies = true; - }); - openai-whisper = with python3.pkgs; toPythonApplication openai-whisper; openai-whisper-cpp = darwin.apple_sdk_11_0.callPackage ../tools/audio/openai-whisper-cpp {