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}:
21
22buildPythonPackage rec {
23 pname = "fnllm";
24 version = "0.2.8";
25 pyproject = true;
26
27 disabled = pythonOlder "3.11";
28
29 src = fetchPypi {
30 inherit pname version;
31 hash = "sha256-FafxygW5aZ3U24mesFZI5cmLd1L1FE8rHOrOgL3R+9g=";
32 };
33
34 build-system = [ hatchling ];
35
36 dependencies = [
37 aiolimiter
38 httpx
39 json-repair
40 pydantic
41 tenacity
42 ];
43
44 optional-dependencies = {
45 azure = [
46 azure-identity
47 azure-storage-blob
48 ];
49 openai = [
50 openai
51 tiktoken
52 ];
53 };
54
55 nativeCheckInputs = [
56 polyfactory
57 pytest-asyncio
58 pytest-cov-stub
59 pytestCheckHook
60 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
61
62 pythonImportsCheck = [ "fnllm" ];
63
64 disabledTests = [
65 # Tests require network access
66 "chat"
67 "embeddings"
68 "rate_limited"
69 "test_default_operations"
70 "test_estimate_request_tokens"
71 "test_replace_value"
72 "test_text_service_encode_decode"
73 "test_count_tokens"
74 "trim_to_max_tokens"
75 "test_split"
76 "test_clear"
77 "test_handles_common_errors"
78 "test_children"
79 ];
80
81 meta = {
82 description = "A function-based LLM protocol and wrapper";
83 homepage = "https://github.com/microsoft/essex-toolkit/tree/main/python/fnllm";
84 license = lib.licenses.mit;
85 maintainers = with lib.maintainers; [ fab ];
86 };
87}