1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 pdm-backend, 8 9 # dependencies 10 langchain-core, 11 openai, 12 tiktoken, 13 14 # tests 15 freezegun, 16 langchain-tests, 17 lark, 18 pandas, 19 pytest-asyncio, 20 pytest-cov-stub, 21 pytestCheckHook, 22 pytest-mock, 23 pytest-socket, 24 requests-mock, 25 responses, 26 syrupy, 27 toml, 28 29 # passthru 30 gitUpdater, 31}: 32 33buildPythonPackage rec { 34 pname = "langchain-openai"; 35 version = "0.3.28"; 36 pyproject = true; 37 38 src = fetchFromGitHub { 39 owner = "langchain-ai"; 40 repo = "langchain"; 41 tag = "langchain-openai==${version}"; 42 hash = "sha256-HpAdCHxmfGJcqXArvtlYagNuEBGBjrbICIwh9nI0qMQ="; 43 }; 44 45 sourceRoot = "${src.name}/libs/partners/openai"; 46 47 build-system = [ pdm-backend ]; 48 49 pythonRelaxDeps = [ 50 # Each component release requests the exact latest core. 51 # That prevents us from updating individual components. 52 "langchain-core" 53 ]; 54 55 dependencies = [ 56 langchain-core 57 openai 58 tiktoken 59 ]; 60 61 nativeCheckInputs = [ 62 freezegun 63 langchain-tests 64 lark 65 pandas 66 pytest-asyncio 67 pytest-cov-stub 68 pytestCheckHook 69 pytest-mock 70 pytest-socket 71 requests-mock 72 responses 73 syrupy 74 toml 75 ]; 76 77 enabledTestPaths = [ "tests/unit_tests" ]; 78 79 disabledTests = [ 80 # These tests require network access 81 "test__convert_dict_to_message_tool_call" 82 "test__get_encoding_model" 83 "test_azure_openai_api_key_is_secret_string" 84 "test_azure_openai_api_key_masked_when_passed_from_env" 85 "test_azure_openai_api_key_masked_when_passed_via_constructor" 86 "test_azure_openai_secrets" 87 "test_azure_openai_uses_actual_secret_value_from_secretstr" 88 "test_azure_serialized_secrets" 89 "test_chat_openai_get_num_tokens" 90 "test_embed_documents_with_custom_chunk_size" 91 "test_get_num_tokens_from_messages" 92 "test_get_token_ids" 93 "test_init_o1" 94 "test_openai_get_num_tokens" 95 ]; 96 97 disabledTestPaths = [ 98 # TODO recheck on next update. Langchain has been working on Pydantic errors. 99 # ValidationError from pydantic 100 "tests/unit_tests/chat_models/test_responses_stream.py" 101 ]; 102 103 pythonImportsCheck = [ "langchain_openai" ]; 104 105 passthru = { 106 # python updater script sets the wrong tag 107 skipBulkUpdate = true; 108 updateScript = gitUpdater { 109 rev-prefix = "langchain-openai=="; 110 }; 111 }; 112 113 meta = { 114 changelog = "https://github.com/langchain-ai/langchain/releases/tag/${src.tag}"; 115 description = "Integration package connecting OpenAI and LangChain"; 116 homepage = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/openai"; 117 license = lib.licenses.mit; 118 maintainers = with lib.maintainers; [ 119 natsukium 120 sarahec 121 ]; 122 }; 123}