1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, aiohttp
5, matplotlib
6, numpy
7, openpyxl
8, pandas
9, pandas-stubs
10, plotly
11, pytest-asyncio
12, pytest-mock
13, pytestCheckHook
14, pythonOlder
15, requests
16, scikit-learn
17, tenacity
18, tqdm
19, typing-extensions
20, wandb
21, withOptionalDependencies ? false
22}:
23
24buildPythonPackage rec {
25 pname = "openai";
26 version = "0.28.1";
27 format = "setuptools";
28
29 disabled = pythonOlder "3.7.1";
30
31 src = fetchFromGitHub {
32 owner = "openai";
33 repo = "openai-python";
34 rev = "refs/tags/v${version}";
35 hash = "sha256-liJyeGxnYIC/jUQKdeATHpVJb/12KGbeM94Y2YQphfY=";
36 };
37
38 propagatedBuildInputs = [
39 aiohttp
40 requests
41 tqdm
42 ] ++ lib.optionals (pythonOlder "3.8") [
43 typing-extensions
44 ] ++ lib.optionals withOptionalDependencies (builtins.attrValues {
45 inherit (passthru.optional-dependencies) embeddings wandb;
46 });
47
48 passthru.optional-dependencies = {
49 datalib = [
50 numpy
51 openpyxl
52 pandas
53 pandas-stubs
54 ];
55 embeddings = [
56 matplotlib
57 plotly
58 scikit-learn
59 tenacity
60 ] ++ passthru.optional-dependencies.datalib;
61 wandb = [
62 wandb
63 ] ++ passthru.optional-dependencies.datalib;
64 };
65
66 pythonImportsCheck = [
67 "openai"
68 ];
69
70 nativeCheckInputs = [
71 pytestCheckHook
72 pytest-asyncio
73 pytest-mock
74 ];
75
76 pytestFlagsArray = [
77 "openai/tests"
78 ];
79
80 OPENAI_API_KEY = "sk-foo";
81
82 disabledTestPaths = [
83 # Requires a real API key
84 "openai/tests/test_endpoints.py"
85 "openai/tests/asyncio/test_endpoints.py"
86 # openai: command not found
87 "openai/tests/test_file_cli.py"
88 "openai/tests/test_long_examples_validator.py"
89 ];
90
91 meta = with lib; {
92 description = "Python client library for the OpenAI API";
93 homepage = "https://github.com/openai/openai-python";
94 changelog = "https://github.com/openai/openai-python/releases/tag/v${version}";
95 license = licenses.mit;
96 maintainers = with maintainers; [ malo ];
97 };
98}