Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134{ lib, buildPythonPackage, fetchFromGitHub, setuptools, anyio, asyncer, cachetools, cloudpickle, datamodel-code-generator, diskcache, gepa, json-repair, litellm, mcp, numpy, openai, orjson, pillow, pydantic, pyprojectVersionPatchHook, pytestCheckHook, pytest-asyncio, regex, requests, tenacity, tqdm, typeguard, xxhash,}:
buildPythonPackage (finalAttrs: { pname = "dspy"; version = "3.2.1"; pyproject = true; __structuredAttrs = true;
src = fetchFromGitHub { owner = "stanfordnlp"; repo = "dspy"; tag = finalAttrs.version; hash = "sha256-xquV+FyDfejm1SCWYfuiezIkyutmm/1zOvd5X+oElrM="; };
build-system = [ setuptools ];
nativeBuildInputs = [ pyprojectVersionPatchHook ];
dependencies = [ anyio asyncer cachetools cloudpickle diskcache gepa json-repair litellm mcp numpy openai orjson pydantic regex requests tenacity tqdm typeguard xxhash ];
pythonRelaxDeps = [ "asyncer" "gepa" "litellm" "typeguard" ];
# optuna is an optional dependency that dspy can use but doesn't require at import time pythonRemoveDeps = [ "optuna" ];
# Prevent litellm from trying to fetch the remote model cost map at import # time, which fails in environments without direct internet access. postPatch = '' sed -i '1i import os; os.environ.setdefault("LITELLM_LOCAL_MODEL_COST_MAP", "true")' dspy/__init__.py '';
pythonImportsCheck = [ "dspy" ];
nativeCheckInputs = [ pytestCheckHook pytest-asyncio datamodel-code-generator pillow ];
# skip tests that need network access disabledTestPaths = [ "tests/signatures/test_adapter_image.py" ];
# These tests start a litellm proxy server subprocess, which isn't available # in the nix build sandbox (upstream skips them on Python 3.14 for the same reason). disabledTests = [ "test_chat_lms_can_be_queried" "test_dspy_cache" "test_lm_calls_support_callables" "test_lm_calls_support_pydantic_models" "test_responses_api_tool_calls" "test_streamify_yields_expected_response_chunks" "test_streaming_response_yields_expected_response_chunks" "test_text_lms_can_be_queried"
# mocked response has no content "test_retry_made_on_system_errors" "test_exponential_backoff_retry"
# claude-3-7-sonnet missing from litellm's model map "test_chat_adapter_native_reasoning" "test_json_adapter_native_reasoning" ];
meta = { description = "Programming — not prompting — language models"; homepage = "https://github.com/stanfordnlp/dspy"; changelog = "https://github.com/stanfordnlp/dspy/releases/tag/${finalAttrs.version}"; maintainers = with lib.maintainers; [ jherland ]; license = lib.licenses.mit; };})