From daf595514d8de6782df91df0467332d75a2df3f6 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 16 Nov 2025 10:31:26 +0000 Subject: [PATCH] python3Packages.shinychat: init at 0.2.8 --- .../python-modules/shinychat/default.nix | 129 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 131 insertions(+) create mode 100644 pkgs/development/python-modules/shinychat/default.nix diff --git a/pkgs/development/python-modules/shinychat/default.nix b/pkgs/development/python-modules/shinychat/default.nix new file mode 100644 index 000000000000..851247d54448 --- /dev/null +++ b/pkgs/development/python-modules/shinychat/default.nix @@ -0,0 +1,129 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + hatch-vcs, + hatchling, + + # dependencies + htmltools, + + # optional-dependencies + anthropic, + chatlas, + google-generativeai, + langchain-core, + ollama, + openai, + pydantic, + tokenizers, + + # tests + pillow, + playwright, + pytest-playwright, + pytestCheckHook, + shiny, + shinychat, +}: + +buildPythonPackage rec { + pname = "shinychat"; + version = "0.2.8"; + pyproject = true; + + src = fetchFromGitHub { + owner = "posit-dev"; + repo = "shinychat"; + tag = "py/v${version}"; + hash = "sha256-thdLaZ+rnD8yumxhjXOLhufcSBD0oNKOWSxxDdJ9tNU="; + }; + + build-system = [ + hatch-vcs + hatchling + ]; + + pythonRemoveDeps = [ + "shiny" # circular dependency + ]; + dependencies = [ + htmltools + ]; + + optional-dependencies = { + providers = [ + anthropic + chatlas + google-generativeai + langchain-core + ollama + openai + pydantic + tokenizers + ]; + }; + + pythonImportsCheck = [ + # ImportError: cannot import name 'Chat' from partially initialized module 'shinychat' (most likely due to a circular import) + # "shinychat" + ]; + + nativeCheckInputs = [ + pillow + playwright + pytest-playwright + pytestCheckHook + shiny + ] + ++ lib.flatten (lib.attrValues optional-dependencies); + + disabledTests = [ + # AssertionError: assert False + "test_as_langchain_message" + + # AssertionError: assert 'AIMessage' == 'BaseMessage' + "test_langchain_normalization" + + # RuntimeError: Failed to download a default tokenizer + "test_chat_message_trimming" + + # Require running a headless chromium browser + "test_latest_stream_result" + "test_validate_chat" + "test_validate_chat_append_user_message" + "test_validate_chat_append_user_message" + "test_validate_chat_basic" + "test_validate_chat_basic" + "test_validate_chat_basic" + "test_validate_chat_basic_error" + "test_validate_chat_input_suggestion" + "test_validate_chat_message_stream_context" + "test_validate_chat_shiny_output" + "test_validate_chat_shiny_output" + "test_validate_chat_stream_result" + "test_validate_chat_transform" + "test_validate_chat_transform_assistant" + "test_validate_chat_transform_assistant" + "test_validate_chat_update_user_input" + "test_validate_stream_basic" + "test_validate_stream_shiny_ui" + ]; + + # Circular dependency with shiny + doCheck = false; + passthru.tests.pytest = shinychat.overridePythonAttrs { + doCheck = true; + }; + + meta = { + description = "Chat UI component for Shiny"; + homepage = "https://posit-dev.github.io/shinychat"; + downloadPage = "https://github.com/posit-dev/shinychat"; + changelog = "https://github.com/posit-dev/shinychat/releases/tag/${src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 243b4739d7a6..745c1d6ae6d4 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -16929,6 +16929,8 @@ self: super: with self; { shiny = callPackage ../development/python-modules/shiny { }; + shinychat = callPackage ../development/python-modules/shinychat { }; + shippinglabel = callPackage ../development/python-modules/shippinglabel { }; shiv = callPackage ../development/python-modules/shiv { };