about summary refs log tree commit diff
path: root/pkgs/development/python-modules/guidance/default.nix
blob: 7cd557d394ef1955eaa05d419838bcd17423ed11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, aiohttp
, diskcache
, gptcache
, msal
, nest-asyncio
, numpy
, openai
, platformdirs
, pygtrie
, pyparsing
, requests
, tiktoken
, torch
}:

buildPythonPackage rec {
  pname = "guidance";
  version = "0.0.64";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "microsoft";
    repo = "guidance";
    rev = "refs/tags/${version}";
    hash = "sha256-tQpDJprxctKI88F+CZ9aSJbVo7tjmI4+VrI+WO4QlxE=";
  };

  propagatedBuildInputs = [
    aiohttp
    diskcache
    gptcache
    msal
    nest-asyncio
    numpy
    openai
    platformdirs
    pygtrie
    pyparsing
    requests
    tiktoken
  ];

  nativeCheckInputs = [
    pytestCheckHook
    torch
  ];

  disabledTests = [
    # require network access
    "test_each_parallel_with_gen_openai"
  ];

  disabledTestPaths = [
    # require network access
    "tests/library/test_gen.py"
    "tests/library/test_include.py"
    "tests/library/test_select.py"
    "tests/llms/test_openai.py"
    "tests/llms/test_transformers.py"
    "tests/test_program.py"
  ];

  preCheck = ''
    export HOME=$TMPDIR
  '';

  pythonImportsCheck = [ "guidance" ];

  meta = with lib; {
    description = "A guidance language for controlling large language models";
    homepage = "https://github.com/microsoft/guidance";
    changelog = "https://github.com/microsoft/guidance/releases/tag/${src.rev}";
    license = licenses.mit;
    maintainers = with maintainers; [ natsukium ];
  };
}