From bc36858dca1c12672ef6146875619efbc00a9947 Mon Sep 17 00:00:00 2001 From: Yun Kim <35776586+Yun-Kim@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:56:32 -0400 Subject: [PATCH] fix(langchain): use correct class names for pinecone vectorstore check [backport 2.9] (#9934) Backport #9759 to 2.9. This PR fixes the class names used to check for `Pinecone` vectorstore instances in the langchain integration. Previously the incorrect base class for all vectorstores was being used, which would mean all vectorstores would return true for this check. Langchain has a tricky versioning system with tons of deprecations and removals (even between minor versions): - `langchain<0.1`: Uses the base `langchain` module to access `langchain.vectorstores.Pinecone` (note this indirectly imports from `langchain_community`. - `langchain>=0.1`: Uses the `langchain_community` module to access `langchain_community.vectorstores.Pinecone` - `langchain>=0.1` but if users have `langchain-pinecone` installed: Uses `langchain_pinecone` module to access `langchain_pinecone.vectorstores.Pinecone` (deprecated, subclass of `PineconeVectorStore`) or `langchain_pinecone.vectorstores.PineconeVectorStore`. We use the above information to use as the logic to check if an instance is a pinecone vectorstore. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --- .riot/requirements/1084a71.txt | 38 ++-- .../requirements/{fa757b7.txt => 1108e76.txt} | 15 +- .riot/requirements/14d34ef.txt | 68 +++--- .riot/requirements/18f914e.txt | 68 +++--- .../requirements/{14531e6.txt => 1a91532.txt} | 17 +- .riot/requirements/1d9420f.txt | 21 +- .riot/requirements/1ec5924.txt | 38 ++-- .riot/requirements/39161c9.txt | 38 ++-- .../requirements/{173ec5d.txt => a5a0786.txt} | 15 +- .riot/requirements/b855d96.txt | 8 +- .riot/requirements/c7ef1de.txt | 8 +- ddtrace/contrib/langchain/patch.py | 6 +- ...pinecone-vectorstore-082c023ccae268e1.yaml | 4 + riotfile.py | 1 + .../openai_retrieval_embedding.yaml | 204 ++++++++++++++++++ .../langchain/test_langchain_community.py | 18 +- .../langchain/test_langchain_llmobs.py | 3 + ...nity.test_faiss_vectorstore_retrieval.json | 89 ++++++++ ...unity.test_lcel_chain_non_dict_input.json} | 0 19 files changed, 492 insertions(+), 167 deletions(-) rename .riot/requirements/{fa757b7.txt => 1108e76.txt} (88%) rename .riot/requirements/{14531e6.txt => 1a91532.txt} (88%) rename .riot/requirements/{173ec5d.txt => a5a0786.txt} (89%) create mode 100644 releasenotes/notes/fix-langchain-pinecone-vectorstore-082c023ccae268e1.yaml create mode 100644 tests/contrib/langchain/cassettes/langchain_community/openai_retrieval_embedding.yaml create mode 100644 tests/snapshots/tests.contrib.langchain.test_langchain_community.test_faiss_vectorstore_retrieval.json rename tests/snapshots/{tests.contrib.langchain.test_langchain_community.test_lcecl_chain_non_dict_input.json => tests.contrib.langchain.test_langchain_community.test_lcel_chain_non_dict_input.json} (100%) diff --git a/.riot/requirements/1084a71.txt b/.riot/requirements/1084a71.txt index d2efd941048..38634478478 100644 --- a/.riot/requirements/1084a71.txt +++ b/.riot/requirements/1084a71.txt @@ -11,36 +11,36 @@ anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 backoff==2.2.1 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 cohere==4.57 -coverage[toml]==7.5.3 +coverage[toml]==7.6.0 dataclasses-json==0.5.14 dnspython==2.6.1 -exceptiongroup==1.2.1 -fastavro==1.9.4 -filelock==3.14.0 +exceptiongroup==1.2.2 +fastavro==1.9.5 +filelock==3.15.4 frozenlist==1.4.1 -fsspec==2024.5.0 +fsspec==2024.6.1 greenlet==3.0.3 -huggingface-hub==0.23.2 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 importlib-metadata==6.11.0 iniconfig==2.0.0 jsonpatch==1.33 -jsonpointer==2.4 +jsonpointer==3.0.0 langchain==0.0.192 langchain-community==0.0.14 langchain-core==0.1.23 langchainplus-sdk==0.0.4 langsmith==0.0.87 loguru==0.7.2 -marshmallow==3.21.2 +marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 -numexpr==2.10.0 +numexpr==2.10.1 numpy==1.26.4 openai==0.27.8 openapi-schema-pydantic==1.2.4 @@ -48,29 +48,29 @@ opentracing==2.4.0 packaging==23.2 pinecone-client==2.2.4 pluggy==1.5.0 -psutil==5.9.8 -pydantic==1.10.15 -pytest==8.2.1 +psutil==6.0.0 +pydantic==1.10.17 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 six==1.16.0 sniffio==1.3.1 sortedcontainers==2.4.0 -sqlalchemy==2.0.30 -tenacity==8.3.0 +sqlalchemy==2.0.31 +tenacity==8.5.0 tiktoken==0.7.0 tomli==2.0.1 tqdm==4.66.4 -typing-extensions==4.12.0 +typing-extensions==4.12.2 typing-inspect==0.9.0 -urllib3==2.2.1 +urllib3==2.2.2 vcrpy==6.0.1 wrapt==1.16.0 yarl==1.9.4 -zipp==3.19.0 +zipp==3.19.2 diff --git a/.riot/requirements/fa757b7.txt b/.riot/requirements/1108e76.txt similarity index 88% rename from .riot/requirements/fa757b7.txt rename to .riot/requirements/1108e76.txt index f5096fd50c6..484216cadf3 100644 --- a/.riot/requirements/fa757b7.txt +++ b/.riot/requirements/1108e76.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --no-annotate .riot/requirements/fa757b7.in +# pip-compile --no-annotate .riot/requirements/1108e76.in # ai21==2.9.2 ai21-tokenizer==0.11.2 @@ -11,8 +11,8 @@ aiosignal==1.3.1 annotated-types==0.7.0 anyio==4.4.0 attrs==23.2.0 -boto3==1.34.145 -botocore==1.34.145 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 cohere==5.4.0 @@ -20,6 +20,7 @@ coverage[toml]==7.6.0 dataclasses-json==0.6.7 distro==1.9.0 exceptiongroup==1.2.2 +faiss-cpu==1.8.0 fastavro==1.9.5 filelock==3.15.4 frozenlist==1.4.1 @@ -29,7 +30,7 @@ h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.24.0 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 iniconfig==2.0.0 @@ -44,7 +45,7 @@ langchain-core==0.1.52 langchain-openai==0.1.6 langchain-pinecone==0.1.0 langchain-text-splitters==0.0.2 -langsmith==0.1.92 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 @@ -60,14 +61,14 @@ pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.2.2 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/.riot/requirements/14d34ef.txt b/.riot/requirements/14d34ef.txt index 8d7bad70884..da6358d874b 100644 --- a/.riot/requirements/14d34ef.txt +++ b/.riot/requirements/14d34ef.txt @@ -4,93 +4,95 @@ # # pip-compile --no-annotate .riot/requirements/14d34ef.in # -ai21==2.5.0 -ai21-tokenizer==0.9.1 +ai21==2.9.2 +ai21-tokenizer==0.11.2 aiohttp==3.9.5 aiosignal==1.3.1 annotated-types==0.7.0 -anthropic==0.28.0 +anthropic==0.31.2 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.122 -botocore==1.34.122 -certifi==2024.6.2 +boto3==1.34.148 +botocore==1.34.148 +certifi==2024.7.4 charset-normalizer==3.3.2 -cohere==5.5.6 -coverage[toml]==7.5.3 +cohere==5.6.2 +coverage[toml]==7.6.0 dataclasses-json==0.6.7 defusedxml==0.7.1 distro==1.9.0 -exceptiongroup==1.2.1 -fastavro==1.9.4 -filelock==3.14.0 +exceptiongroup==1.2.2 +fastavro==1.9.5 +filelock==3.15.4 frozenlist==1.4.1 -fsspec==2024.6.0 +fsspec==2024.6.1 greenlet==3.0.3 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.23.3 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 -importlib-metadata==7.1.0 +importlib-metadata==8.2.0 iniconfig==2.0.0 -jiter==0.4.1 +jiter==0.5.0 jmespath==1.0.1 jsonpatch==1.33 -jsonpointer==2.4 +jsonpointer==3.0.0 langchain==0.2.0 langchain-anthropic==0.1.13 langchain-aws==0.1.6 -langchain-cohere==0.1.5 +langchain-cohere==0.1.8 langchain-core==0.2.0 langchain-openai==0.1.7 -langchain-pinecone==0.1.1 +langchain-pinecone==0.1.3 langchain-text-splitters==0.2.1 -langsmith==0.1.75 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 -numexpr==2.10.0 +numexpr==2.10.1 numpy==1.26.4 -openai==1.33.0 +openai==1.37.0 opentracing==2.4.0 -orjson==3.10.4 +orjson==3.10.6 packaging==23.2 parameterized==0.9.0 -pinecone-client==3.2.2 +pinecone-client==5.0.0 +pinecone-plugin-inference==1.0.2 +pinecone-plugin-interface==0.0.7 pluggy==1.5.0 -psutil==5.9.8 -pydantic==2.7.3 -pydantic-core==2.18.4 -pytest==8.2.2 +psutil==6.0.0 +pydantic==2.8.2 +pydantic-core==2.20.1 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 -s3transfer==0.10.1 +s3transfer==0.10.2 sentencepiece==0.2.0 six==1.16.0 sniffio==1.3.1 sortedcontainers==2.4.0 -sqlalchemy==2.0.30 -tenacity==8.3.0 +sqlalchemy==2.0.31 +tenacity==8.5.0 tiktoken==0.7.0 -tokenizers==0.15.2 +tokenizers==0.19.1 tomli==2.0.1 tqdm==4.66.4 types-requests==2.31.0.6 types-urllib3==1.26.25.14 typing-extensions==4.12.2 typing-inspect==0.9.0 -urllib3==1.26.18 +urllib3==1.26.19 vcrpy==6.0.1 wrapt==1.16.0 yarl==1.9.4 diff --git a/.riot/requirements/18f914e.txt b/.riot/requirements/18f914e.txt index 599ceb20ac5..c5d7b9e2bd1 100644 --- a/.riot/requirements/18f914e.txt +++ b/.riot/requirements/18f914e.txt @@ -4,89 +4,91 @@ # # pip-compile --no-annotate .riot/requirements/18f914e.in # -ai21==2.5.0 -ai21-tokenizer==0.9.1 +ai21==2.9.2 +ai21-tokenizer==0.11.2 aiohttp==3.9.5 aiosignal==1.3.1 annotated-types==0.7.0 -anthropic==0.28.0 +anthropic==0.31.2 anyio==4.4.0 attrs==23.2.0 -boto3==1.34.122 -botocore==1.34.122 -certifi==2024.6.2 +boto3==1.34.148 +botocore==1.34.148 +certifi==2024.7.4 charset-normalizer==3.3.2 -cohere==5.5.6 -coverage[toml]==7.5.3 +cohere==5.6.2 +coverage[toml]==7.6.0 dataclasses-json==0.6.7 defusedxml==0.7.1 distro==1.9.0 -exceptiongroup==1.2.1 -fastavro==1.9.4 -filelock==3.14.0 +exceptiongroup==1.2.2 +fastavro==1.9.5 +filelock==3.15.4 frozenlist==1.4.1 -fsspec==2024.6.0 +fsspec==2024.6.1 greenlet==3.0.3 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.23.3 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 iniconfig==2.0.0 -jiter==0.4.1 +jiter==0.5.0 jmespath==1.0.1 jsonpatch==1.33 -jsonpointer==2.4 +jsonpointer==3.0.0 langchain==0.2.0 langchain-anthropic==0.1.13 langchain-aws==0.1.6 -langchain-cohere==0.1.5 +langchain-cohere==0.1.8 langchain-core==0.2.0 langchain-openai==0.1.7 -langchain-pinecone==0.1.1 +langchain-pinecone==0.1.3 langchain-text-splitters==0.2.1 -langsmith==0.1.75 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 -numexpr==2.10.0 +numexpr==2.10.1 numpy==1.26.4 -openai==1.33.0 +openai==1.37.0 opentracing==2.4.0 -orjson==3.10.4 +orjson==3.10.6 packaging==23.2 parameterized==0.9.0 -pinecone-client==3.2.2 +pinecone-client==5.0.0 +pinecone-plugin-inference==1.0.2 +pinecone-plugin-interface==0.0.7 pluggy==1.5.0 -psutil==5.9.8 -pydantic==2.7.3 -pydantic-core==2.18.4 -pytest==8.2.2 +psutil==6.0.0 +pydantic==2.8.2 +pydantic-core==2.20.1 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 -s3transfer==0.10.1 +s3transfer==0.10.2 sentencepiece==0.2.0 six==1.16.0 sniffio==1.3.1 sortedcontainers==2.4.0 -sqlalchemy==2.0.30 -tenacity==8.3.0 +sqlalchemy==2.0.31 +tenacity==8.5.0 tiktoken==0.7.0 -tokenizers==0.15.2 +tokenizers==0.19.1 tqdm==4.66.4 -types-requests==2.32.0.20240602 +types-requests==2.32.0.20240712 typing-extensions==4.12.2 typing-inspect==0.9.0 -urllib3==2.2.1 +urllib3==2.2.2 vcrpy==6.0.1 wrapt==1.16.0 yarl==1.9.4 diff --git a/.riot/requirements/14531e6.txt b/.riot/requirements/1a91532.txt similarity index 88% rename from .riot/requirements/14531e6.txt rename to .riot/requirements/1a91532.txt index 09ca0bc5401..e6e0075a49b 100644 --- a/.riot/requirements/14531e6.txt +++ b/.riot/requirements/1a91532.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --no-annotate .riot/requirements/14531e6.in +# pip-compile --no-annotate .riot/requirements/1a91532.in # ai21==2.9.2 ai21-tokenizer==0.11.2 @@ -12,8 +12,8 @@ annotated-types==0.7.0 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.145 -botocore==1.34.145 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 cohere==5.4.0 @@ -21,6 +21,7 @@ coverage[toml]==7.6.0 dataclasses-json==0.6.7 distro==1.9.0 exceptiongroup==1.2.2 +faiss-cpu==1.8.0 fastavro==1.9.5 filelock==3.15.4 frozenlist==1.4.1 @@ -30,10 +31,10 @@ h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.24.0 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 -importlib-metadata==8.0.0 +importlib-metadata==8.2.0 iniconfig==2.0.0 jmespath==1.0.1 jsonpatch==1.33 @@ -46,7 +47,7 @@ langchain-core==0.1.52 langchain-openai==0.1.6 langchain-pinecone==0.1.0 langchain-text-splitters==0.0.2 -langsmith==0.1.92 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 @@ -62,14 +63,14 @@ pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.2.2 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/.riot/requirements/1d9420f.txt b/.riot/requirements/1d9420f.txt index b3d040b016f..0f11e9a9742 100644 --- a/.riot/requirements/1d9420f.txt +++ b/.riot/requirements/1d9420f.txt @@ -13,11 +13,11 @@ anthropic==0.31.2 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.145 -botocore==1.34.145 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 -cohere==5.6.1 +cohere==5.6.2 coverage[toml]==7.6.0 dataclasses-json==0.6.7 defusedxml==0.7.1 @@ -32,7 +32,7 @@ h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.24.0 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 iniconfig==2.0.0 @@ -46,34 +46,35 @@ langchain-aws==0.1.6 langchain-cohere==0.1.8 langchain-core==0.2.0 langchain-openai==0.1.7 -langchain-pinecone==0.1.2 +langchain-pinecone==0.1.3 langchain-text-splitters==0.2.1 -langsmith==0.1.92 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 numexpr==2.10.1 numpy==1.26.4 -openai==1.36.0 +openai==1.37.0 opentracing==2.4.0 orjson==3.10.6 packaging==23.2 parameterized==0.9.0 -pinecone-client==4.1.2 +pinecone-client==5.0.0 +pinecone-plugin-inference==1.0.2 pinecone-plugin-interface==0.0.7 pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.2.2 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/.riot/requirements/1ec5924.txt b/.riot/requirements/1ec5924.txt index 6cd3eef8c1b..724a5c6e3a7 100644 --- a/.riot/requirements/1ec5924.txt +++ b/.riot/requirements/1ec5924.txt @@ -10,36 +10,36 @@ aiosignal==1.3.1 anyio==4.4.0 attrs==23.2.0 backoff==2.2.1 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 cohere==4.57 -coverage[toml]==7.5.3 +coverage[toml]==7.6.0 dataclasses-json==0.5.14 dnspython==2.6.1 -exceptiongroup==1.2.1 -fastavro==1.9.4 -filelock==3.14.0 +exceptiongroup==1.2.2 +fastavro==1.9.5 +filelock==3.15.4 frozenlist==1.4.1 -fsspec==2024.5.0 +fsspec==2024.6.1 greenlet==3.0.3 -huggingface-hub==0.23.2 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 importlib-metadata==6.11.0 iniconfig==2.0.0 jsonpatch==1.33 -jsonpointer==2.4 +jsonpointer==3.0.0 langchain==0.0.192 langchain-community==0.0.14 langchain-core==0.1.23 langchainplus-sdk==0.0.4 langsmith==0.0.87 loguru==0.7.2 -marshmallow==3.21.2 +marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 -numexpr==2.10.0 +numexpr==2.10.1 numpy==1.26.4 openai==0.27.8 openapi-schema-pydantic==1.2.4 @@ -47,28 +47,28 @@ opentracing==2.4.0 packaging==23.2 pinecone-client==2.2.4 pluggy==1.5.0 -psutil==5.9.8 -pydantic==1.10.15 -pytest==8.2.1 +psutil==6.0.0 +pydantic==1.10.17 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 six==1.16.0 sniffio==1.3.1 sortedcontainers==2.4.0 -sqlalchemy==2.0.30 -tenacity==8.3.0 +sqlalchemy==2.0.31 +tenacity==8.5.0 tiktoken==0.7.0 tqdm==4.66.4 -typing-extensions==4.12.0 +typing-extensions==4.12.2 typing-inspect==0.9.0 -urllib3==2.2.1 +urllib3==2.2.2 vcrpy==6.0.1 wrapt==1.16.0 yarl==1.9.4 -zipp==3.19.0 +zipp==3.19.2 diff --git a/.riot/requirements/39161c9.txt b/.riot/requirements/39161c9.txt index 789b1dcc3c8..e5f67f5d84b 100644 --- a/.riot/requirements/39161c9.txt +++ b/.riot/requirements/39161c9.txt @@ -11,36 +11,36 @@ anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 backoff==2.2.1 -certifi==2024.2.2 +certifi==2024.7.4 charset-normalizer==3.3.2 cohere==4.57 -coverage[toml]==7.5.3 +coverage[toml]==7.6.0 dataclasses-json==0.5.14 dnspython==2.6.1 -exceptiongroup==1.2.1 -fastavro==1.9.4 -filelock==3.14.0 +exceptiongroup==1.2.2 +fastavro==1.9.5 +filelock==3.15.4 frozenlist==1.4.1 -fsspec==2024.5.0 +fsspec==2024.6.1 greenlet==3.0.3 -huggingface-hub==0.23.2 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 importlib-metadata==6.11.0 iniconfig==2.0.0 jsonpatch==1.33 -jsonpointer==2.4 +jsonpointer==3.0.0 langchain==0.0.192 langchain-community==0.0.14 langchain-core==0.1.23 langchainplus-sdk==0.0.4 langsmith==0.0.87 loguru==0.7.2 -marshmallow==3.21.2 +marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 mypy-extensions==1.0.0 -numexpr==2.10.0 +numexpr==2.10.1 numpy==1.26.4 openai==0.27.8 openapi-schema-pydantic==1.2.4 @@ -48,29 +48,29 @@ opentracing==2.4.0 packaging==23.2 pinecone-client==2.2.4 pluggy==1.5.0 -psutil==5.9.8 -pydantic==1.10.15 -pytest==8.2.1 +psutil==6.0.0 +pydantic==1.10.17 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 six==1.16.0 sniffio==1.3.1 sortedcontainers==2.4.0 -sqlalchemy==2.0.30 -tenacity==8.3.0 +sqlalchemy==2.0.31 +tenacity==8.5.0 tiktoken==0.7.0 tomli==2.0.1 tqdm==4.66.4 -typing-extensions==4.12.0 +typing-extensions==4.12.2 typing-inspect==0.9.0 -urllib3==1.26.18 +urllib3==1.26.19 vcrpy==6.0.1 wrapt==1.16.0 yarl==1.9.4 -zipp==3.19.0 +zipp==3.19.2 diff --git a/.riot/requirements/173ec5d.txt b/.riot/requirements/a5a0786.txt similarity index 89% rename from .riot/requirements/173ec5d.txt rename to .riot/requirements/a5a0786.txt index 1fc7e74e574..bbaa71a245e 100644 --- a/.riot/requirements/173ec5d.txt +++ b/.riot/requirements/a5a0786.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --no-annotate .riot/requirements/173ec5d.in +# pip-compile --no-annotate .riot/requirements/a5a0786.in # ai21==2.9.2 ai21-tokenizer==0.11.2 @@ -12,8 +12,8 @@ annotated-types==0.7.0 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.145 -botocore==1.34.145 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 cohere==5.4.0 @@ -21,6 +21,7 @@ coverage[toml]==7.6.0 dataclasses-json==0.6.7 distro==1.9.0 exceptiongroup==1.2.2 +faiss-cpu==1.8.0 fastavro==1.9.5 filelock==3.15.4 frozenlist==1.4.1 @@ -30,7 +31,7 @@ h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 httpx-sse==0.4.0 -huggingface-hub==0.24.0 +huggingface-hub==0.24.2 hypothesis==6.45.0 idna==3.7 iniconfig==2.0.0 @@ -45,7 +46,7 @@ langchain-core==0.1.52 langchain-openai==0.1.6 langchain-pinecone==0.1.0 langchain-text-splitters==0.0.2 -langsmith==0.1.92 +langsmith==0.1.93 marshmallow==3.21.3 mock==5.1.0 multidict==6.0.5 @@ -61,14 +62,14 @@ pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.2.2 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/.riot/requirements/b855d96.txt b/.riot/requirements/b855d96.txt index 18fc8b365f7..059a9beeedd 100644 --- a/.riot/requirements/b855d96.txt +++ b/.riot/requirements/b855d96.txt @@ -13,8 +13,8 @@ anthropic==0.31.2 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.147 -botocore==1.34.147 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 cohere==5.6.2 @@ -71,7 +71,7 @@ pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.3.1 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 @@ -79,7 +79,7 @@ pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pytz==2024.1 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/.riot/requirements/c7ef1de.txt b/.riot/requirements/c7ef1de.txt index 738e0afe788..58b9d26ad9a 100644 --- a/.riot/requirements/c7ef1de.txt +++ b/.riot/requirements/c7ef1de.txt @@ -13,8 +13,8 @@ anthropic==0.31.2 anyio==4.4.0 async-timeout==4.0.3 attrs==23.2.0 -boto3==1.34.147 -botocore==1.34.147 +boto3==1.34.148 +botocore==1.34.148 certifi==2024.7.4 charset-normalizer==3.3.2 cohere==5.6.2 @@ -70,7 +70,7 @@ pluggy==1.5.0 psutil==6.0.0 pydantic==2.8.2 pydantic-core==2.20.1 -pytest==8.3.1 +pytest==8.3.2 pytest-asyncio==0.21.1 pytest-cov==5.0.0 pytest-mock==3.14.0 @@ -78,7 +78,7 @@ pytest-randomly==3.15.0 python-dateutil==2.9.0.post0 pytz==2024.1 pyyaml==6.0.1 -regex==2024.5.15 +regex==2024.7.24 requests==2.32.3 s3transfer==0.10.2 sentencepiece==0.2.0 diff --git a/ddtrace/contrib/langchain/patch.py b/ddtrace/contrib/langchain/patch.py index ab2aab8a9ac..ee98d62acd4 100644 --- a/ddtrace/contrib/langchain/patch.py +++ b/ddtrace/contrib/langchain/patch.py @@ -185,10 +185,10 @@ def _is_pinecone_vectorstore_instance(instance): """ try: if not PATCH_LANGCHAIN_V0 and langchain_pinecone: - return isinstance(instance, langchain_pinecone.VectorStore) + return isinstance(instance, langchain_pinecone.PineconeVectorStore) if not PATCH_LANGCHAIN_V0 and langchain_community: - return isinstance(instance, langchain_community.vectorstores.VectorStore) - return isinstance(instance, langchain.vectorstores.VectorStore) + return isinstance(instance, langchain_community.vectorstores.Pinecone) + return isinstance(instance, langchain.vectorstores.Pinecone) except (AttributeError, ModuleNotFoundError, ImportError): return False diff --git a/releasenotes/notes/fix-langchain-pinecone-vectorstore-082c023ccae268e1.yaml b/releasenotes/notes/fix-langchain-pinecone-vectorstore-082c023ccae268e1.yaml new file mode 100644 index 00000000000..a1222a1b291 --- /dev/null +++ b/releasenotes/notes/fix-langchain-pinecone-vectorstore-082c023ccae268e1.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + langchain: This fix resolves an issue where the wrong langchain class name was being used to check for Pinecone vectorstore instances. diff --git a/riotfile.py b/riotfile.py index db475c7fb24..b6acb9f01d3 100644 --- a/riotfile.py +++ b/riotfile.py @@ -2517,6 +2517,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): "pinecone-client": latest, "botocore": latest, "cohere": "==5.4.0", + "faiss-cpu": "==1.8.0", } ), Venv( diff --git a/tests/contrib/langchain/cassettes/langchain_community/openai_retrieval_embedding.yaml b/tests/contrib/langchain/cassettes/langchain_community/openai_retrieval_embedding.yaml new file mode 100644 index 00000000000..a7615c41e2d --- /dev/null +++ b/tests/contrib/langchain/cassettes/langchain_community/openai_retrieval_embedding.yaml @@ -0,0 +1,204 @@ +interactions: +- request: + body: '{"input": [[3923, 574, 279, 1984, 315, 279, 1566, 1296, 3319, 30]], "model": + "text-embedding-ada-002", "encoding_format": "base64"}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '131' + content-type: + - application/json + cookie: + - _cfuvid=v6MSy3Sk6pxtoYL8kXXuNiO2j0OK_HAODXl1hNcZp0o-1710190352774-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.34.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.34.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.10.5 + method: POST + uri: https://api.openai.com/v1/embeddings + response: + body: + string: !!binary | + H4sIAAAAAAAAA1SYyQ6zPJOF930Vr75tWsqMi39HmMNgEyCE9AoIIUAGJhvwf/Ot5G11qzcsbCN5 + qHrOqfr3f/z5888nrfJs+Odff/55lv3wz39+x27JkPzzrz//9R9//vz58+/f9/+tzF9pfruV7+K3 + /DdZvm/59M+//qz+d+T/Fv3rzz9H/ZmyQ34zlWF5h3bXxUqCX5TUaBrj+gPvSJaYpdizPRmHx0Lc + vqKI6afuyeek3q4A4zonEusEm43Pgwf4cJuI2T7EYH6cdgkAXufEGTe6Tcnp2QpnVrwoqo1XNeyk + woPNzmgx69aPrrndohVCK0KY8ZhF3t7N4AWfs8CIvM0NhRt1gEXKXIupg47QdHpGGBqxSIkVK5oy + Pz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fJJ25o0HfB5yB6R839ETXUsD6I76jkadQ27+FwW/exFpxotu9yIVY+2E46Q/d + rksnEs/j8Y72/qniI/8za13bqQjbuyd1VuE+6hT1R4VHbc3oNgw30aCIi7QmpIipVZnvoPkE1zvk + feJwl16fom93jwPqTp+S6nNrXXP5BgyecpLS2/JwR+2lLY8w9bduQc3r4fYy3ElfGKqFXzfjeZv0 + jEmHDESfyaY2+ScTgKKg+8TrF+TDrCeKGFjOyt4aINpyiyzDnted+73fYcw/DDrs4AXZVwyJSrGJ + HJdmNHiNXsDI2/jUj+43qRLDMbVTOvH8Xu3QMPUHuPF6hwGXzdJGU56lSozrGs2IAX9NUwH//uPP + P/9vmjAoykf8HgcD2rhv//7vqMDf4SP8W5Lk3zEE1oRJ/Ne//plA+Kuqy6Jq/78tX/Gn+etffy7+ + mTX4qy3b8P2/1/8YH/XvP/4DAAD//wMA6kC8UuAgAAA= + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8a1bbdde9f747116-YYZ + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json + Date: + - Thu, 11 Jul 2024 21:03:42 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=fYix13QP3Bd6KiFCyoChA8w6ga_JVC5tkdoj3opBso8-1720731822-1.0.1.1-M2houut9UkQkRvdPvKSbYt3Wrz1IQoBml8h0p7iqR5pO81rF5t7TrQPDMhHdiRtHmyb2p4ur_L3jLTndFcF4KQ; + path=/; expires=Thu, 11-Jul-24 21:33:42 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=qNbRTOfo3UydlqBO7v8kwcY5Q5R56nFBWE2L8VVztSA-1720731822090-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + access-control-allow-origin: + - '*' + alt-svc: + - h3=":443"; ma=86400 + openai-model: + - text-embedding-ada-002 + openai-organization: + - datadog-4 + openai-processing-ms: + - '20' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '10000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '9999989' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_1e7aa7af282a135a9d87eaac31f00a35 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/contrib/langchain/test_langchain_community.py b/tests/contrib/langchain/test_langchain_community.py index e6e2e3bf4fd..528d3678897 100644 --- a/tests/contrib/langchain/test_langchain_community.py +++ b/tests/contrib/langchain/test_langchain_community.py @@ -1296,7 +1296,7 @@ async def test_lcel_chain_batch_async(langchain_core, langchain_openai, request_ @pytest.mark.snapshot -def test_lcecl_chain_non_dict_input(langchain_core): +def test_lcel_chain_non_dict_input(langchain_core): """ Tests that non-dict inputs (specifically also non-string) are stringified properly """ @@ -1305,3 +1305,19 @@ def test_lcecl_chain_non_dict_input(langchain_core): sequence = add_one | multiply_two sequence.invoke(1) + + +@pytest.mark.snapshot +def test_faiss_vectorstore_retrieval(langchain_community, langchain_openai, request_vcr): + if langchain_community is None: + pytest.skip("langchain-community not installed which is required for this test.") + pytest.importorskip("faiss", reason="faiss required for this test.") + with mock.patch("langchain_openai.OpenAIEmbeddings._get_len_safe_embeddings", return_value=[[0.0] * 1536]): + with request_vcr.use_cassette("openai_embedding_query.yaml"): + faiss = langchain_community.vectorstores.faiss.FAISS.from_texts( + ["this is a test query."], + embedding=langchain_openai.OpenAIEmbeddings(), + ) + retriever = faiss.as_retriever() + with request_vcr.use_cassette("openai_retrieval_embedding.yaml"): + retriever.invoke("What was the message of the last test query?") diff --git a/tests/contrib/langchain/test_langchain_llmobs.py b/tests/contrib/langchain/test_langchain_llmobs.py index 731b9370d9c..18e9105fcc4 100644 --- a/tests/contrib/langchain/test_langchain_llmobs.py +++ b/tests/contrib/langchain/test_langchain_llmobs.py @@ -15,6 +15,7 @@ from tests.llmobs._utils import _expected_llmobs_non_llm_span_event from tests.subprocesstest import SubprocessTestCase from tests.subprocesstest import run_in_subprocess +from tests.utils import flaky if PATCH_LANGCHAIN_V0: @@ -324,6 +325,7 @@ def test_llmobs_chain_schema_io(self, langchain, mock_llmobs_span_writer, mock_t _assert_expected_llmobs_llm_span(trace[1], mock_llmobs_span_writer, mock_io=True) +@flaky(1735812000, reason="Community cassette tests are flaky") @pytest.mark.skipif(PATCH_LANGCHAIN_V0, reason="These tests are for langchain >= 0.1.0") class TestLLMObsLangchainCommunity(BaseTestLLMObsLangchain): cassette_subdirectory_name = "langchain_community" @@ -507,6 +509,7 @@ def test_llmobs_chain_schema_io(self, langchain_core, langchain_openai, mock_llm _assert_expected_llmobs_llm_span(trace[1], mock_llmobs_span_writer, mock_io=True) +@flaky(1735812000, reason="Community cassette tests are flaky") @pytest.mark.skipif(PATCH_LANGCHAIN_V0, reason="These tests are for langchain >= 0.1.0") class TestLangchainTraceStructureWithLlmIntegrations(SubprocessTestCase): bedrock_env_config = dict( diff --git a/tests/snapshots/tests.contrib.langchain.test_langchain_community.test_faiss_vectorstore_retrieval.json b/tests/snapshots/tests.contrib.langchain.test_langchain_community.test_faiss_vectorstore_retrieval.json new file mode 100644 index 00000000000..477574379a9 --- /dev/null +++ b/tests/snapshots/tests.contrib.langchain.test_langchain_community.test_faiss_vectorstore_retrieval.json @@ -0,0 +1,89 @@ +[[ + { + "name": "langchain.request", + "service": "", + "resource": "langchain_openai.embeddings.base.OpenAIEmbeddings", + "trace_id": 0, + "span_id": 1, + "parent_id": 0, + "type": "", + "error": 0, + "meta": { + "_dd.p.dm": "-0", + "_dd.p.tid": "668c5dde00000000", + "langchain.request.api_key": "...key>", + "langchain.request.inputs.0.text": "this is a test query.", + "langchain.request.model": "text-embedding-ada-002", + "langchain.request.provider": "openai", + "langchain.request.type": "embedding", + "language": "python", + "runtime-id": "2a1d7ab4ff064afb95e895ce7aa565e0" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_dd.tracer_kr": 1.0, + "_sampling_priority_v1": 1, + "langchain.request.input_count": 1, + "langchain.response.outputs.0.embedding_length": 1536, + "process_id": 69484 + }, + "duration": 406798000, + "start": 1720475102021903000 + }], +[ + { + "name": "langchain.request", + "service": "", + "resource": "langchain_community.vectorstores.faiss.FAISS", + "trace_id": 1, + "span_id": 1, + "parent_id": 0, + "type": "", + "error": 0, + "meta": { + "_dd.p.dm": "-0", + "_dd.p.tid": "668c5dde00000000", + "langchain.request.api_key": "", + "langchain.request.provider": "faiss", + "langchain.request.query": "What was the message of the last test query?", + "langchain.request.type": "similarity_search", + "langchain.response.document.0.page_content": "this is a test query.", + "language": "python", + "runtime-id": "2a1d7ab4ff064afb95e895ce7aa565e0" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_dd.tracer_kr": 1.0, + "_sampling_priority_v1": 1, + "langchain.response.document_count": 1, + "process_id": 69484 + }, + "duration": 3710000, + "start": 1720475102468386000 + }, + { + "name": "langchain.request", + "service": "", + "resource": "langchain_openai.embeddings.base.OpenAIEmbeddings", + "trace_id": 1, + "span_id": 2, + "parent_id": 1, + "type": "", + "error": 0, + "meta": { + "langchain.request.api_key": "...key>", + "langchain.request.inputs.0.text": "What was the message of the last test query?", + "langchain.request.model": "text-embedding-ada-002", + "langchain.request.provider": "openai", + "langchain.request.type": "embedding" + }, + "metrics": { + "_dd.measured": 1, + "langchain.request.input_count": 1, + "langchain.response.outputs.0.embedding_length": 1536 + }, + "duration": 1714000, + "start": 1720475102468505000 + }]] diff --git a/tests/snapshots/tests.contrib.langchain.test_langchain_community.test_lcecl_chain_non_dict_input.json b/tests/snapshots/tests.contrib.langchain.test_langchain_community.test_lcel_chain_non_dict_input.json similarity index 100% rename from tests/snapshots/tests.contrib.langchain.test_langchain_community.test_lcecl_chain_non_dict_input.json rename to tests/snapshots/tests.contrib.langchain.test_langchain_community.test_lcel_chain_non_dict_input.json