From 07e7069044cb4030cb433d6503dbc81185409e65 Mon Sep 17 00:00:00 2001 From: natsukium Date: Fri, 3 Jan 2025 22:37:18 +0900 Subject: [PATCH 1/2] python312Packages.guidance: fix build --- .../python-modules/guidance/default.nix | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/guidance/default.nix b/pkgs/development/python-modules/guidance/default.nix index 676e2f3a5299..43091110602b 100644 --- a/pkgs/development/python-modules/guidance/default.nix +++ b/pkgs/development/python-modules/guidance/default.nix @@ -11,6 +11,8 @@ diskcache, fastapi, gptcache, + huggingface-hub, + jsonschema, msal, numpy, openai, @@ -18,6 +20,7 @@ platformdirs, protobuf, pyformlang, + pydantic, requests, tiktoken, torch, @@ -57,15 +60,29 @@ buildPythonPackage rec { platformdirs protobuf pyformlang + pydantic requests tiktoken uvicorn ]; + optional-dependencies = { + azureai = [ openai ]; + openai = [ openai ]; + schemas = [ jsonschema ]; + server = [ + fastapi + uvicorn + ]; + }; + nativeCheckInputs = [ + huggingface-hub pytestCheckHook torch - ]; + ] ++ optional-dependencies.schemas; + + pytestFlagsArray = [ "tests/unit" ]; disabledTests = [ # require network access @@ -79,6 +96,10 @@ buildPythonPackage rec { "test_recursion_error" "test_openai_class_detection" "test_openai_chat_without_roles" + "test_local_image" + "test_remote_image" + "test_image_from_bytes" + "test_remote_image_not_found" # flaky tests "test_remote_mock_gen" # frequently fails when building packages in parallel @@ -86,11 +107,12 @@ buildPythonPackage rec { disabledTestPaths = [ # require network access - "tests/library/test_gen.py" + "tests/unit/test_tokenizers.py" ]; preCheck = '' export HOME=$TMPDIR + rm tests/conftest.py ''; pythonImportsCheck = [ "guidance" ]; From b8edf7befdd74b253e2f8c6b3a1bd3c77f41cbcf Mon Sep 17 00:00:00 2001 From: natsukium Date: Fri, 3 Jan 2025 22:39:23 +0900 Subject: [PATCH 2/2] python312Packages.guidance: refactor --- .../python-modules/guidance/default.nix | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/pkgs/development/python-modules/guidance/default.nix b/pkgs/development/python-modules/guidance/default.nix index 43091110602b..38eebb5654ae 100644 --- a/pkgs/development/python-modules/guidance/default.nix +++ b/pkgs/development/python-modules/guidance/default.nix @@ -3,23 +3,17 @@ buildPythonPackage, fetchFromGitHub, pytestCheckHook, - pythonOlder, pybind11, setuptools, - wheel, - aiohttp, diskcache, fastapi, - gptcache, huggingface-hub, jsonschema, - msal, numpy, openai, ordered-set, platformdirs, protobuf, - pyformlang, pydantic, requests, tiktoken, @@ -32,8 +26,6 @@ buildPythonPackage rec { version = "0.1.16"; pyproject = true; - disabled = pythonOlder "3.8"; - src = fetchFromGitHub { owner = "guidance-ai"; repo = "guidance"; @@ -41,29 +33,20 @@ buildPythonPackage rec { hash = "sha256-dPakdT97cuLv4OwdaUFncopD5X6uXGyUjwzqn9fxnhU="; }; - nativeBuildInputs = [ pybind11 ]; - build-system = [ + pybind11 setuptools - wheel ]; dependencies = [ - aiohttp diskcache - fastapi - gptcache - msal numpy - openai ordered-set platformdirs protobuf - pyformlang pydantic requests tiktoken - uvicorn ]; optional-dependencies = { @@ -119,11 +102,11 @@ buildPythonPackage rec { __darwinAllowLocalNetworking = true; - meta = with lib; { + meta = { description = "Guidance language for controlling large language models"; homepage = "https://github.com/guidance-ai/guidance"; - changelog = "https://github.com/guidance-ai/guidance/releases/tag/${version}"; - license = licenses.mit; - maintainers = with maintainers; [ natsukium ]; + changelog = "https://github.com/guidance-ai/guidance/releases/tag/${src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ natsukium ]; }; }