From 2aa13f1e10a24bd27eb32012e7c00cf584039f28 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Mon, 13 Nov 2023 09:12:21 -0800 Subject: [PATCH] chore: bump momento dependency version and refactor search hit usage (#13111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** Bumps the Momento dependency to the latest version and refactors the usage of `SearchHit` in the Momento Vector Index (MVI) vector store integration. This change is a one liner where we use the preferred attribute `score` to read the query-document similarity instead of `distance`. The latest versions of Momento clients will use this attribute going forward. **Dependencies** Updated the Momento dependency to latest version. **Tests** 💚 I re-ran the existing MVI integration tests (`tests/integration_tests/vectorstores/test_momento_vector_index.py`) and they pass. **Review** cc @baskaryan @eyurtsev --- .../vectorstores/momento_vector_index.py | 2 +- libs/langchain/poetry.lock | 16 ++++++++-------- libs/langchain/pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/langchain/langchain/vectorstores/momento_vector_index.py b/libs/langchain/langchain/vectorstores/momento_vector_index.py index be56363cbe4..e79d48c46f6 100644 --- a/libs/langchain/langchain/vectorstores/momento_vector_index.py +++ b/libs/langchain/langchain/vectorstores/momento_vector_index.py @@ -308,7 +308,7 @@ class MomentoVectorIndex(VectorStore): for hit in response.hits: text = cast(str, hit.metadata.pop(self.text_field)) doc = Document(page_content=text, metadata=hit.metadata) - pair = (doc, hit.distance) + pair = (doc, hit.score) results.append(pair) return results diff --git a/libs/langchain/poetry.lock b/libs/langchain/poetry.lock index 16c54fbcaaf..3cf055cafad 100644 --- a/libs/langchain/poetry.lock +++ b/libs/langchain/poetry.lock @@ -4708,29 +4708,29 @@ files = [ [[package]] name = "momento" -version = "1.12.0" +version = "1.13.0" description = "SDK for Momento" optional = true python-versions = ">=3.7,<4.0" files = [ - {file = "momento-1.12.0-py3-none-any.whl", hash = "sha256:1dcb3ebadba67bc5e49337c433119d3857ff2e1e36627a8fcdadcc5db9a2f785"}, - {file = "momento-1.12.0.tar.gz", hash = "sha256:31918c4e56b8db2f632a465c3a7df656666b8dab9efdcd49c61f3451d7bc481d"}, + {file = "momento-1.13.0-py3-none-any.whl", hash = "sha256:dd5ace5b8d679e882afcefaa16bc413973c270b0a7a1c6c45f3eb60b0b9526de"}, + {file = "momento-1.13.0.tar.gz", hash = "sha256:39419627542b8f5997a777ff91aa3aaf6406b7d76fb83cd84284a0f7d1f9e356"}, ] [package.dependencies] grpcio = ">=1.46.0,<2.0.0" -momento-wire-types = ">=0.86.0,<0.87.0" +momento-wire-types = ">=0.91.1,<0.92.0" pyjwt = ">=2.4.0,<3.0.0" [[package]] name = "momento-wire-types" -version = "0.86.0" +version = "0.91.4" description = "Momento Client Proto Generated Files" optional = true python-versions = ">=3.7,<4.0" files = [ - {file = "momento_wire_types-0.86.0-py3-none-any.whl", hash = "sha256:1079f61f3a0aa90865870b116a8699289e6f03b969a349265abdd605b073251c"}, - {file = "momento_wire_types-0.86.0.tar.gz", hash = "sha256:7695a448382fbfda8ad7a51c307b34a2ef3d81d883f77b71891c27a4c25aed18"}, + {file = "momento_wire_types-0.91.4-py3-none-any.whl", hash = "sha256:f296249693de2f6c383a397e7616b84dd83dfd466743d34b035b90865000a2a8"}, + {file = "momento_wire_types-0.91.4.tar.gz", hash = "sha256:de8cd14a12835d95997eb9b753ea47e1a5d2916658ec9320e416da8bd835fdff"}, ] [package.dependencies] @@ -11006,4 +11006,4 @@ text-helpers = ["chardet"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "53e759b0e865e43984f1b1617958b4ddd27c840624e3e0763a1c8cdd79e616bb" +content-hash = "ef4fb00c31e567dea3c4a1230dfea40edc9ffcf1c2b1d30d146904f696d07a22" diff --git a/libs/langchain/pyproject.toml b/libs/langchain/pyproject.toml index f7a3bf192c6..09995dd23fd 100644 --- a/libs/langchain/pyproject.toml +++ b/libs/langchain/pyproject.toml @@ -95,7 +95,7 @@ azure-ai-formrecognizer = {version = "^3.2.1", optional = true} azure-ai-vision = {version = "^0.11.1b1", optional = true} azure-cognitiveservices-speech = {version = "^1.28.0", optional = true} py-trello = {version = "^0.19.0", optional = true} -momento = {version = "^1.10.1", optional = true} +momento = {version = "^1.13.0", optional = true} bibtexparser = {version = "^1.4.0", optional = true} singlestoredb = {version = "^0.7.1", optional = true} pyspark = {version = "^3.4.0", optional = true}