1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, pytestCheckHook
5, aiohttp
6, diskcache
7, gptcache
8, msal
9, nest-asyncio
10, numpy
11, openai
12, platformdirs
13, pygtrie
14, pyparsing
15, requests
16, tiktoken
17, torch
18}:
19
20buildPythonPackage rec {
21 pname = "guidance";
22 version = "0.0.64";
23 format = "setuptools";
24
25 src = fetchFromGitHub {
26 owner = "microsoft";
27 repo = "guidance";
28 rev = "refs/tags/${version}";
29 hash = "sha256-tQpDJprxctKI88F+CZ9aSJbVo7tjmI4+VrI+WO4QlxE=";
30 };
31
32 propagatedBuildInputs = [
33 aiohttp
34 diskcache
35 gptcache
36 msal
37 nest-asyncio
38 numpy
39 openai
40 platformdirs
41 pygtrie
42 pyparsing
43 requests
44 tiktoken
45 ];
46
47 nativeCheckInputs = [
48 pytestCheckHook
49 torch
50 ];
51
52 disabledTests = [
53 # require network access
54 "test_each_parallel_with_gen_openai"
55 ];
56
57 disabledTestPaths = [
58 # require network access
59 "tests/library/test_gen.py"
60 "tests/library/test_include.py"
61 "tests/library/test_select.py"
62 "tests/llms/test_openai.py"
63 "tests/llms/test_transformers.py"
64 "tests/test_program.py"
65 ];
66
67 preCheck = ''
68 export HOME=$TMPDIR
69 '';
70
71 pythonImportsCheck = [ "guidance" ];
72
73 meta = with lib; {
74 description = "A guidance language for controlling large language models";
75 homepage = "https://github.com/microsoft/guidance";
76 changelog = "https://github.com/microsoft/guidance/releases/tag/${src.rev}";
77 license = licenses.mit;
78 maintainers = with maintainers; [ natsukium ];
79 };
80}