1{
2 lib,
3 aiolimiter,
4 azure-identity,
5 azure-storage-blob,
6 buildPythonPackage,
7 fetchPypi,
8 hatchling,
9 httpx,
10 json-repair,
11 openai,
12 polyfactory,
13 pydantic,
14 pytest-asyncio,
15 pytest-cov-stub,
16 pytestCheckHook,
17 pythonOlder,
18 tenacity,
19 tiktoken,
20 uv-dynamic-versioning,
21}:
22
23buildPythonPackage rec {
24 pname = "fnllm";
25 version = "0.4.1";
26 pyproject = true;
27
28 disabled = pythonOlder "3.11";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-gKdFBpNpG/CDLhKi1wQgZHv+o1pDy5HEqcteLzkXK1A=";
33 };
34
35 build-system = [
36 hatchling
37 uv-dynamic-versioning
38 ];
39
40 dependencies = [
41 aiolimiter
42 httpx
43 json-repair
44 pydantic
45 tenacity
46 ];
47
48 optional-dependencies = {
49 azure = [
50 azure-identity
51 azure-storage-blob
52 ];
53 openai = [
54 openai
55 tiktoken
56 ];
57 };
58
59 nativeCheckInputs = [
60 polyfactory
61 pytest-asyncio
62 pytest-cov-stub
63 pytestCheckHook
64 ]
65 ++ lib.flatten (builtins.attrValues optional-dependencies);
66
67 pythonImportsCheck = [ "fnllm" ];
68
69 disabledTests = [
70 # Tests require network access
71 "chat"
72 "embeddings"
73 "rate_limited"
74 "test_default_operations"
75 "test_estimate_request_tokens"
76 "test_replace_value"
77 "test_text_service_encode_decode"
78 "test_count_tokens"
79 "trim_to_max_tokens"
80 "test_split"
81 "test_clear"
82 "test_handles_common_errors"
83 "test_children"
84 ];
85
86 meta = {
87 description = "Function-based LLM protocol and wrapper";
88 homepage = "https://github.com/microsoft/essex-toolkit/tree/main/python/fnllm";
89 license = lib.licenses.mit;
90 maintainers = with lib.maintainers; [ fab ];
91 };
92}