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 ]
61 ++ lib.flatten (builtins.attrValues optional-dependencies);
62
63 pythonImportsCheck = [ "fnllm" ];
64
65 disabledTests = [
66 # Tests require network access
67 "chat"
68 "embeddings"
69 "rate_limited"
70 "test_default_operations"
71 "test_estimate_request_tokens"
72 "test_replace_value"
73 "test_text_service_encode_decode"
74 "test_count_tokens"
75 "trim_to_max_tokens"
76 "test_split"
77 "test_clear"
78 "test_handles_common_errors"
79 "test_children"
80 ];
81
82 meta = {
83 description = "Function-based LLM protocol and wrapper";
84 homepage = "https://github.com/microsoft/essex-toolkit/tree/main/python/fnllm";
85 license = lib.licenses.mit;
86 maintainers = with lib.maintainers; [ fab ];
87 };
88}