From 2a70916caf88cf1bc3305d2e695e709c4ae3170d Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Fri, 2 Feb 2024 14:34:52 +0300 Subject: [PATCH 01/41] Add support for Upstash Vector --- .../vectorstores/__init__.py | 9 + .../vectorstores/upstash.py | 372 ++++++++++++++++++ 2 files changed, 381 insertions(+) create mode 100644 libs/community/langchain_community/vectorstores/upstash.py diff --git a/libs/community/langchain_community/vectorstores/__init__.py b/libs/community/langchain_community/vectorstores/__init__.py index 61b573bb64952..b73e3e5f9f5fd 100644 --- a/libs/community/langchain_community/vectorstores/__init__.py +++ b/libs/community/langchain_community/vectorstores/__init__.py @@ -422,6 +422,12 @@ def _import_typesense() -> Any: return Typesense +def _import_upstash() -> Any: + from langchain_community.vectorstores.upstash import UpstashVectorStore + + return UpstashVectorStore + + def _import_usearch() -> Any: from langchain_community.vectorstores.usearch import USearch @@ -609,6 +615,8 @@ def __getattr__(name: str) -> Any: return _import_timescalevector() elif name == "Typesense": return _import_typesense() + elif name == "UpstashVectorStore": + return _import_upstash() elif name == "USearch": return _import_usearch() elif name == "Vald": @@ -695,6 +703,7 @@ def __getattr__(name: str) -> Any: "Tigris", "TimescaleVector", "Typesense", + "UpstashVectorStore", "USearch", "Vald", "Vearch", diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py new file mode 100644 index 0000000000000..1e6f82102eda8 --- /dev/null +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -0,0 +1,372 @@ +from __future__ import annotations + +import logging +import uuid +import asyncio +from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple + +import numpy as np +from langchain_core.documents import Document +from langchain_core.embeddings import Embeddings +from langchain_core.utils.iter import batch_iterate +from langchain_core.vectorstores import VectorStore + +from langchain_community.vectorstores.utils import ( + maximal_marginal_relevance, +) + +if TYPE_CHECKING: + from upstash_vector import AsyncIndex + +logger = logging.getLogger(__name__) + + +class UpstashVectorStore(VectorStore): + """Upstash Vector vector store. + + To use, you should have the ``upstash_vector`` python package installed. + + Create a new Upstash Vector database and copy the `index_url` and `index_token`. + + Example: + .. code-block:: python + + from langchain_community.vectorstores.upstash import UpstashVectorStore + from langchain_community.embeddings.openai import OpenAIEmbeddings + + embeddings = OpenAIEmbeddings() + vectorstore = UpstashVectorStore(embedding=embeddings, index_url="...", index_token="...") + """ + + def __init__( + self, + text_key: Optional[str] = "text", + index: Optional[AsyncIndex] = None, + index_url: Optional[str] = None, + index_token: Optional[str] = None, + embedding: Optional[Embeddings] = None, + ): + """ + Constructor for UpstashVectorStore. + + If index or index_url and index_token are not provided, the constructor will attempt to + create an index using the environment variables `UPSTASH_VECTOR_URL` and `UPSTASH_VECTOR_TOKEN`. + + Args: + text_key: Key to store the text in metadata. + index: UpstashVector AsyncIndex object. + index_url: URL of the UpstashVector index. + index_token: Token of the UpstashVector index. + embedding: Embeddings object. + + Example: + .. code-block:: python + + from langchain_community.vectorstores.upstash import UpstashVectorStore + from langchain_community.embeddings.openai import OpenAIEmbeddings + + embeddings = OpenAIEmbeddings() + vectorstore = UpstashVectorStore(embedding=embeddings, index_url="...", index_token="...") + """ + + try: + from upstash_vector import AsyncIndex + except ImportError: + raise ImportError( + "Could not import upstash_vector python package. " + "Please install it with `pip install upstash_vector`." + ) + + if index: + if not isinstance(index, AsyncIndex): + raise ValueError( + f"Passed index object should be an instance of upstash_vector.AsyncIndex, " f"got {type(index)}" + ) + self._index = index + logger.info("Using the index passed as parameter") + elif index_url and index_token: + self._index = AsyncIndex(url=index_url, token=index_token) + logger.info( + "Created index from the index_url and index_token parameters") + else: + self._index = AsyncIndex.from_env() + logger.info("Created index using environment variables") + + self._embeddings = embedding + self._text_key = text_key + + @property + def embeddings(self) -> Optional[Embeddings]: + """Access the query embedding object if available.""" + return self._embeddings + + def _embed_documents(self, texts: Iterable[str]) -> List[List[float]]: + """Embed strings using the embeddings object""" + return self._embeddings.embed_documents(list(texts)) + + def _embed_query(self, text: str) -> List[float]: + """Embed query text using the embeddings object.""" + return self._embeddings.embed_query(text) + + def add_texts( + self, + texts: Iterable[str], + metadatas: Optional[List[dict]] = None, + ids: Optional[List[str]] = None, + batch_size: int = 32, + embedding_chunk_size: int = 1000, + **kwargs: Any, + ) -> List[str]: + """ + Get the embeddings for the texts and add them to the vectorstore. + + Texts are sent to the embeddings object in batches of size `embedding_chunk_size`. + The embeddings are then upserted into the vectorstore in batches of size `batch_size`. + + For OpenAI embeddings use embedding_chunk_size>1000 and batch_size~64 for best performance. + + Args: + texts: Iterable of strings to add to the vectorstore. + metadatas: Optional list of metadatas associated with the texts. + ids: Optional list of ids to associate with the texts. + batch_size: Batch size to use when upserting the embeddings. Upstash supports at max 1000 vectors per request. + embedding_batch_size: Chunk size to use when embedding the texts. + + Returns: + List of ids from adding the texts into the vectorstore. + + """ + texts = list(texts) + ids = ids or [str(uuid.uuid4()) for _ in texts] + metadatas = metadatas or [{} for _ in texts] + + # Add text to metadata + for metadata, text in zip(metadatas, texts): + metadata[self._text_key] = text + + # For loops to avoid memory issues and optimize when using HTTP based embeddings + # The first loop runs the embeddings, it benefits when using OpenAI embeddings + # The second loops runs the pinecone upsert asynchronously. + for i in range(0, len(texts), embedding_chunk_size): + chunk_texts = texts[i: i + embedding_chunk_size] + chunk_ids = ids[i: i + embedding_chunk_size] + chunk_metadatas = metadatas[i: i + embedding_chunk_size] + embeddings = self._embed_documents(chunk_texts) + + async_res = [ + self._index.upsert( + vectors=batch, + **kwargs, + ) + for batch in batch_iterate( + batch_size, zip(chunk_ids, embeddings, chunk_metadatas) + ) + ] + + async def upsert_all(): + return await asyncio.gather(*async_res) + asyncio.run(upsert_all()) + + return ids + + def similarity_search_with_score( + self, + query: str, + k: int = 4, + ) -> List[Tuple[Document, float]]: + """Retrieve texts most similar to query and convert the result to `Document` objects. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + filter: Dictionary of argument(s) to filter on metadata + + Returns: + List of Documents most similar to the query and score for each + """ + return self.similarity_search_by_vector_with_score( + self._embed_query(query), k=k + ) + + def similarity_search_by_vector_with_score( + self, + embedding: List[float], + *, + k: int = 4, + ) -> List[Tuple[Document, float]]: + """Return texts whose embedding is closest to the given embedding""" + + docs = [] + results = asyncio.run(self._index.query( + vector=embedding, + top_k=k, + include_metadata=True, + )) + for res in results: + metadata = res.metadata + if metadata and self._text_key in metadata: + text = metadata.pop(self._text_key) + score = res.score + docs.append( + (Document(page_content=text, metadata=metadata), score)) + else: + logger.warning( + f"Found document with no `{self._text_key}` key. Skipping." + ) + return docs + + def similarity_search( + self, + query: str, + k: int = 4, + **kwargs: Any, + ) -> List[Document]: + """Return documents most similar to query. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + filter: Dictionary of argument(s) to filter on metadata + + Returns: + List of Documents most similar to the query and score for each + """ + docs_and_scores = self.similarity_search_with_score( + query, k=k, **kwargs + ) + return [doc for doc, _ in docs_and_scores] + + def max_marginal_relevance_search_by_vector( + self, + embedding: List[float], + k: int = 4, + fetch_k: int = 20, + lambda_mult: float = 0.5, + ) -> List[Document]: + """Return docs selected using the maximal marginal relevance. + + Maximal marginal relevance optimizes for similarity to query AND diversity + among selected documents. + + Args: + embedding: Embedding to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + fetch_k: Number of Documents to fetch to pass to MMR algorithm. + lambda_mult: Number between 0 and 1 that determines the degree + of diversity among the results with 0 corresponding + to maximum diversity and 1 to minimum diversity. + Defaults to 0.5. + Returns: + List of Documents selected by maximal marginal relevance. + """ + results = asyncio.run(self._index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + )) + mmr_selected = maximal_marginal_relevance( + np.array([embedding], dtype=np.float32), + [item.vector for item in results], + k=k, + lambda_mult=lambda_mult, + ) + selected = [results[i].metadata for i in mmr_selected] + return [ + Document(page_content=metadata.pop( + (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + for metadata in selected + ] + + def max_marginal_relevance_search( + self, + query: str, + k: int = 4, + fetch_k: int = 20, + lambda_mult: float = 0.5, + ) -> List[Document]: + """Return docs selected using the maximal marginal relevance. + + Maximal marginal relevance optimizes for similarity to query AND diversity + among selected documents. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + fetch_k: Number of Documents to fetch to pass to MMR algorithm. + lambda_mult: Number between 0 and 1 that determines the degree + of diversity among the results with 0 corresponding + to maximum diversity and 1 to minimum diversity. + Defaults to 0.5. + Returns: + List of Documents selected by maximal marginal relevance. + """ + embedding = self._embed_query(query) + return self.max_marginal_relevance_search_by_vector( + embedding=embedding, k=k, fetch_k=fetch_k, lambda_mult=lambda_mult + ) + + @classmethod + def from_texts( + cls, + texts: List[str], + embedding: Embeddings, + metadatas: Optional[List[dict]] = None, + ids: Optional[List[str]] = None, + embedding_chunk_size: int = 1000, + batch_size: int = 32, + text_key: str = "text", + index: Optional[AsyncIndex] = None, + index_url: Optional[str] = None, + index_token: Optional[str] = None, + ) -> UpstashVectorStore: + """Create a new UpstashVectorStore from a list of texts. + + Example: + .. code-block:: python + from langchain_community.vectorstores.upstash import UpstashVectorStore + from langchain_community.embeddings import OpenAIEmbeddings + + embeddings = OpenAIEmbeddings() + vector_store = UpstashVectorStore.from_texts( + texts, + embeddings, + ) + """ + vector_store = cls(embedding=embedding, text_key=text_key, + index=index, index_url=index_url, index_token=index_token) + + vector_store.add_texts( + texts, + metadatas=metadatas, + ids=ids, + batch_size=batch_size, + embedding_chunk_size=embedding_chunk_size, + ) + return vector_store + + def delete( + self, + ids: Optional[List[str]] = None, + delete_all: Optional[bool] = None, + batch_size=1000 + ) -> None: + """Delete by vector IDs + + Args: + ids: List of ids to delete. + delete_all: Delete all vectors in the index. + batch_size: Batch size to use when deleting the embeddings. Upstash supports at max 1000 deletions per request. + """ + + if delete_all: + self._index.reset() + elif ids is not None: + for i in range(0, len(ids), batch_size): + chunk = ids[i: i + batch_size] + self._index.delete(ids=chunk) + else: + raise ValueError( + "Either ids or delete_all should be provided") + + return None From 8b1a907ac36d841ea992c4bb13d9d62e194751b7 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 4 Feb 2024 23:32:17 +0300 Subject: [PATCH 02/41] Add integration tests --- .../vectorstores/test_upstash.py | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 libs/community/tests/integration_tests/vectorstores/test_upstash.py diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py new file mode 100644 index 0000000000000..dd4383ce40da6 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -0,0 +1,167 @@ +"""Test Upstash Vector functionality.""" + +import os + +import pytest +import requests +from langchain_core.documents import Document + +from langchain_community.vectorstores.upstash import UpstashVectorStore +from tests.integration_tests.vectorstores.fake_embeddings import ( + FakeEmbeddings, +) + + +def is_api_accessible(url: str) -> bool: + try: + response = requests.get(url) + return response.status_code == 200 + except Exception: + return False + + +def test_upstash() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings() + ) + output = docsearch.similarity_search("foo", k=1) + assert output == [Document(page_content="foo")] + + +async def test_upstash_async() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings() + ) + output = await docsearch.asimilarity_search("foo", k=1) + assert output == [Document(page_content="foo")] + + +def test_upstash_with_metadatas() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + docsearch = UpstashVectorStore.from_texts( + + texts=texts, + embedding=FakeEmbeddings(), + metadatas=metadatas, + ) + output = docsearch.similarity_search("foo", k=1) + assert output == [Document(page_content="foo", metadata={"page": "0"})] + + +def test_upstash_with_metadatas_with_scores() -> None: + """Test end to end construction and scored search.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + docsearch = UpstashVectorStore.from_texts( + + texts=texts, + embedding=FakeEmbeddings(), + metadatas=metadatas, + ) + output = docsearch.similarity_search_with_score("foo", k=1) + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + + +def test_upstash_with_metadatas_with_scores_using_vector() -> None: + """Test end to end construction and scored search, using embedding vector.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + embeddings = FakeEmbeddings() + + docsearch = UpstashVectorStore.from_texts( + texts=texts, + embedding=embeddings, + metadatas=metadatas, + ) + embedded_query = embeddings.embed_query("foo") + output = docsearch.similarity_search_by_vector_with_score( + embedding=embedded_query, k=1 + ) + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + + +def test_upstash_mmr() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings() + ) + output = docsearch.max_marginal_relevance_search("foo", k=1) + assert output == [Document(page_content="foo")] + + +def test_upstash_mmr_by_vector() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + embeddings = FakeEmbeddings() + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=embeddings + ) + embedded_query = embeddings.embed_query("foo") + output = docsearch.max_marginal_relevance_search_by_vector( + embedded_query, k=1) + assert output == [Document(page_content="foo")] + + +def test_upstash_with_relevance_score() -> None: + """Test to make sure the relevance score is scaled to 0-1.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + docsearch = UpstashVectorStore.from_texts( + texts=texts, + embedding=FakeEmbeddings(), + metadatas=metadatas, + ) + output = docsearch.similarity_search_with_relevance_scores("foo", k=3) + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 1.0), + (Document(page_content="bar", metadata={"page": "1"}), 0.8), + (Document(page_content="baz", metadata={"page": "2"}), 0.5), + ] + + +def test_init_from_client() -> None: + from upstash_vector import AsyncIndex + + index = AsyncIndex.from_env() + + store = UpstashVectorStore(index=index) + + assert store.info() is not None + + +@pytest.skip() +def test_init_from_credentials() -> None: + + store = UpstashVectorStore( + index_url=os.environ["UPSTASH_VECTOR_URL"], index_token=os.environ["UPSTASH_VECTOR_TOKEN"]) + + assert store.info() is not None + + +def test_upstash_add_documents_no_metadata() -> None: + db = UpstashVectorStore(embedding=FakeEmbeddings()) + db.add_documents([Document(page_content="foo")]) + + +def test_upstash_add_documents_mixed_metadata() -> None: + db = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"baz": 1}), + ] + ids = ["0", "1"] + actual_ids = db.add_documents(docs, ids=ids) + assert actual_ids == ids + search = db.similarity_search("foo bar") + assert sorted(search, key=lambda d: d.page_content) == sorted( + docs, key=lambda d: d.page_content + ) From 1e77f547839b4f05bc762bdc8c9e59ef9b9e0f27 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 4 Feb 2024 23:32:31 +0300 Subject: [PATCH 03/41] Add info api --- .../langchain_community/vectorstores/upstash.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 1e6f82102eda8..40f93039ccf21 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -370,3 +370,15 @@ def delete( "Either ids or delete_all should be provided") return None + + def info(self): + """Get statistics about the index. + + Returns: + - total number of vectors + - total number of vectors waiting to be indexed + - total size of the index on disk in bytes + - dimension count for the index + - similarity function selected for the index + """ + return self._index.info() From 82e38c514bfb3f3f468e000eed26da76d2bbcdd3 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 01:08:21 +0300 Subject: [PATCH 04/41] Add name to indexing.ipynb --- docs/docs/modules/data_connection/indexing.ipynb | 2 +- .../tests/unit_tests/vectorstores/test_indexing_docs.py | 1 + libs/community/tests/unit_tests/vectorstores/test_public_api.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/docs/modules/data_connection/indexing.ipynb b/docs/docs/modules/data_connection/indexing.ipynb index b888a77958b87..b7c9ef81a5bc8 100644 --- a/docs/docs/modules/data_connection/indexing.ipynb +++ b/docs/docs/modules/data_connection/indexing.ipynb @@ -60,7 +60,7 @@ " * document addition by id (`add_documents` method with `ids` argument)\n", " * delete by id (`delete` method with `ids` argument)\n", "\n", - "Compatible Vectorstores: `AnalyticDB`, `AstraDB`, `AwaDB`, `Bagel`, `Cassandra`, `Chroma`, `DashVector`, `DatabricksVectorSearch`, `DeepLake`, `Dingo`, `ElasticVectorSearch`, `ElasticsearchStore`, `FAISS`, `HanaDB`, `Milvus`, `MyScale`, `PGVector`, `Pinecone`, `Qdrant`, `Redis`, `ScaNN`, `SupabaseVectorStore`, `SurrealDBStore`, `TimescaleVector`, `Vald`, `Vearch`, `VespaStore`, `Weaviate`, `ZepVectorStore`.\n", + "Compatible Vectorstores: `AnalyticDB`, `AstraDB`, `AwaDB`, `Bagel`, `Cassandra`, `Chroma`, `DashVector`, `DatabricksVectorSearch`, `DeepLake`, `Dingo`, `ElasticVectorSearch`, `ElasticsearchStore`, `FAISS`, `HanaDB`, `Milvus`, `MyScale`, `PGVector`, `Pinecone`, `Qdrant`, `Redis`, `ScaNN`, `SupabaseVectorStore`, `SurrealDBStore`, `TimescaleVector`, `UpstashVectorStore`, `Vald`, `Vearch`, `VespaStore`, `Weaviate`, `ZepVectorStore`.\n", " \n", "## Caution\n", "\n", diff --git a/libs/community/tests/unit_tests/vectorstores/test_indexing_docs.py b/libs/community/tests/unit_tests/vectorstores/test_indexing_docs.py index 1232d6bb9a681..bad114be0bfd2 100644 --- a/libs/community/tests/unit_tests/vectorstores/test_indexing_docs.py +++ b/libs/community/tests/unit_tests/vectorstores/test_indexing_docs.py @@ -74,6 +74,7 @@ def check_compatibility(vector_store: VectorStore) -> bool: "SurrealDBStore", "TileDB", "TimescaleVector", + "UpstashVectorStore", "Vald", "Vearch", "VespaStore", diff --git a/libs/community/tests/unit_tests/vectorstores/test_public_api.py b/libs/community/tests/unit_tests/vectorstores/test_public_api.py index 53713f3e1bebf..78ac11fc4eec7 100644 --- a/libs/community/tests/unit_tests/vectorstores/test_public_api.py +++ b/libs/community/tests/unit_tests/vectorstores/test_public_api.py @@ -62,6 +62,7 @@ "Tigris", "TimescaleVector", "Typesense", + "UpstashVectorStore", "USearch", "Vald", "Vearch", From 763c59b837548ce4824bdeefa01eab48f670fe14 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 01:13:22 +0300 Subject: [PATCH 05/41] Fix formatting --- .../vectorstores/upstash.py | 67 ++++++++++--------- .../vectorstores/test_upstash.py | 32 +++------ 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 40f93039ccf21..5a723715543a8 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -1,8 +1,8 @@ from __future__ import annotations +import asyncio import logging import uuid -import asyncio from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple import numpy as np @@ -80,14 +80,14 @@ def __init__( if index: if not isinstance(index, AsyncIndex): raise ValueError( - f"Passed index object should be an instance of upstash_vector.AsyncIndex, " f"got {type(index)}" + f"Passed index object should be an instance of upstash_vector.AsyncIndex, " + f"got {type(index)}" ) self._index = index logger.info("Using the index passed as parameter") elif index_url and index_token: self._index = AsyncIndex(url=index_url, token=index_token) - logger.info( - "Created index from the index_url and index_token parameters") + logger.info("Created index from the index_url and index_token parameters") else: self._index = AsyncIndex.from_env() logger.info("Created index using environment variables") @@ -148,9 +148,9 @@ def add_texts( # The first loop runs the embeddings, it benefits when using OpenAI embeddings # The second loops runs the pinecone upsert asynchronously. for i in range(0, len(texts), embedding_chunk_size): - chunk_texts = texts[i: i + embedding_chunk_size] - chunk_ids = ids[i: i + embedding_chunk_size] - chunk_metadatas = metadatas[i: i + embedding_chunk_size] + chunk_texts = texts[i : i + embedding_chunk_size] + chunk_ids = ids[i : i + embedding_chunk_size] + chunk_metadatas = metadatas[i : i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) async_res = [ @@ -165,6 +165,7 @@ def add_texts( async def upsert_all(): return await asyncio.gather(*async_res) + asyncio.run(upsert_all()) return ids @@ -197,18 +198,19 @@ def similarity_search_by_vector_with_score( """Return texts whose embedding is closest to the given embedding""" docs = [] - results = asyncio.run(self._index.query( - vector=embedding, - top_k=k, - include_metadata=True, - )) + results = asyncio.run( + self._index.query( + vector=embedding, + top_k=k, + include_metadata=True, + ) + ) for res in results: metadata = res.metadata if metadata and self._text_key in metadata: text = metadata.pop(self._text_key) score = res.score - docs.append( - (Document(page_content=text, metadata=metadata), score)) + docs.append((Document(page_content=text, metadata=metadata), score)) else: logger.warning( f"Found document with no `{self._text_key}` key. Skipping." @@ -231,9 +233,7 @@ def similarity_search( Returns: List of Documents most similar to the query and score for each """ - docs_and_scores = self.similarity_search_with_score( - query, k=k, **kwargs - ) + docs_and_scores = self.similarity_search_with_score(query, k=k, **kwargs) return [doc for doc, _ in docs_and_scores] def max_marginal_relevance_search_by_vector( @@ -259,12 +259,14 @@ def max_marginal_relevance_search_by_vector( Returns: List of Documents selected by maximal marginal relevance. """ - results = asyncio.run(self._index.query( - vector=embedding, - top_k=fetch_k, - include_vectors=True, - include_metadata=True, - )) + results = asyncio.run( + self._index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + ) + ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), [item.vector for item in results], @@ -273,8 +275,7 @@ def max_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop( - (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True for metadata in selected ] @@ -333,8 +334,13 @@ def from_texts( embeddings, ) """ - vector_store = cls(embedding=embedding, text_key=text_key, - index=index, index_url=index_url, index_token=index_token) + vector_store = cls( + embedding=embedding, + text_key=text_key, + index=index, + index_url=index_url, + index_token=index_token, + ) vector_store.add_texts( texts, @@ -349,7 +355,7 @@ def delete( self, ids: Optional[List[str]] = None, delete_all: Optional[bool] = None, - batch_size=1000 + batch_size=1000, ) -> None: """Delete by vector IDs @@ -363,11 +369,10 @@ def delete( self._index.reset() elif ids is not None: for i in range(0, len(ids), batch_size): - chunk = ids[i: i + batch_size] + chunk = ids[i : i + batch_size] self._index.delete(ids=chunk) else: - raise ValueError( - "Either ids or delete_all should be provided") + raise ValueError("Either ids or delete_all should be provided") return None diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index dd4383ce40da6..632f4b1e0f82d 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -23,9 +23,7 @@ def is_api_accessible(url: str) -> bool: def test_upstash() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings() - ) + docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) output = docsearch.similarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -33,9 +31,7 @@ def test_upstash() -> None: async def test_upstash_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings() - ) + docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) output = await docsearch.asimilarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -45,7 +41,6 @@ def test_upstash_with_metadatas() -> None: texts = ["foo", "bar", "baz"] metadatas = [{"page": str(i)} for i in range(len(texts))] docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings(), metadatas=metadatas, @@ -59,14 +54,12 @@ def test_upstash_with_metadatas_with_scores() -> None: texts = ["foo", "bar", "baz"] metadatas = [{"page": str(i)} for i in range(len(texts))] docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings(), metadatas=metadatas, ) output = docsearch.similarity_search_with_score("foo", k=1) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 0.0)] def test_upstash_with_metadatas_with_scores_using_vector() -> None: @@ -84,16 +77,13 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: output = docsearch.similarity_search_by_vector_with_score( embedding=embedded_query, k=1 ) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 0.0)] def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings() - ) + docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) output = docsearch.max_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -102,12 +92,9 @@ def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] embeddings = FakeEmbeddings() - docsearch = UpstashVectorStore.from_texts( - texts=texts, embedding=embeddings - ) + docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=embeddings) embedded_query = embeddings.embed_query("foo") - output = docsearch.max_marginal_relevance_search_by_vector( - embedded_query, k=1) + output = docsearch.max_marginal_relevance_search_by_vector(embedded_query, k=1) assert output == [Document(page_content="foo")] @@ -140,9 +127,10 @@ def test_init_from_client() -> None: @pytest.skip() def test_init_from_credentials() -> None: - store = UpstashVectorStore( - index_url=os.environ["UPSTASH_VECTOR_URL"], index_token=os.environ["UPSTASH_VECTOR_TOKEN"]) + index_url=os.environ["UPSTASH_VECTOR_URL"], + index_token=os.environ["UPSTASH_VECTOR_TOKEN"], + ) assert store.info() is not None From f63414d33261a1898d0f72189d5d67b6497876d7 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 11:20:12 +0300 Subject: [PATCH 06/41] Fix formatting --- .../vectorstores/upstash.py | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 5a723715543a8..5760507e005e5 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -35,7 +35,11 @@ class UpstashVectorStore(VectorStore): from langchain_community.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() - vectorstore = UpstashVectorStore(embedding=embeddings, index_url="...", index_token="...") + vectorstore = UpstashVectorStore( + embedding=embeddings, + index_url="...", + index_token="..." + ) """ def __init__( @@ -49,8 +53,9 @@ def __init__( """ Constructor for UpstashVectorStore. - If index or index_url and index_token are not provided, the constructor will attempt to - create an index using the environment variables `UPSTASH_VECTOR_URL` and `UPSTASH_VECTOR_TOKEN`. + If index or index_url and index_token are not provided, the constructor will + attempt to create an index using the environment variables + `UPSTASH_VECTOR_URL`and `UPSTASH_VECTOR_TOKEN`. Args: text_key: Key to store the text in metadata. @@ -66,7 +71,11 @@ def __init__( from langchain_community.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() - vectorstore = UpstashVectorStore(embedding=embeddings, index_url="...", index_token="...") + vectorstore = UpstashVectorStore( + embedding=embeddings, + index_url="...", + index_token="..." + ) """ try: @@ -80,14 +89,16 @@ def __init__( if index: if not isinstance(index, AsyncIndex): raise ValueError( - f"Passed index object should be an instance of upstash_vector.AsyncIndex, " + "Passed index object should be an " + "instance of upstash_vector.AsyncIndex, " f"got {type(index)}" ) self._index = index logger.info("Using the index passed as parameter") elif index_url and index_token: self._index = AsyncIndex(url=index_url, token=index_token) - logger.info("Created index from the index_url and index_token parameters") + logger.info( + "Created index from the index_url and index_token parameters") else: self._index = AsyncIndex.from_env() logger.info("Created index using environment variables") @@ -120,16 +131,20 @@ def add_texts( """ Get the embeddings for the texts and add them to the vectorstore. - Texts are sent to the embeddings object in batches of size `embedding_chunk_size`. - The embeddings are then upserted into the vectorstore in batches of size `batch_size`. + Texts are sent to the embeddings object + in batches of size `embedding_chunk_size`. + The embeddings are then upserted into the vectorstore + in batches of size `batch_size`. - For OpenAI embeddings use embedding_chunk_size>1000 and batch_size~64 for best performance. + For OpenAI embeddings use embedding_chunk_size>1000 + and batch_size~64 for best performance. Args: texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. ids: Optional list of ids to associate with the texts. - batch_size: Batch size to use when upserting the embeddings. Upstash supports at max 1000 vectors per request. + batch_size: Batch size to use when upserting the embeddings. + Upstash supports at max 1000 vectors per request. embedding_batch_size: Chunk size to use when embedding the texts. Returns: @@ -148,9 +163,9 @@ def add_texts( # The first loop runs the embeddings, it benefits when using OpenAI embeddings # The second loops runs the pinecone upsert asynchronously. for i in range(0, len(texts), embedding_chunk_size): - chunk_texts = texts[i : i + embedding_chunk_size] - chunk_ids = ids[i : i + embedding_chunk_size] - chunk_metadatas = metadatas[i : i + embedding_chunk_size] + chunk_texts = texts[i: i + embedding_chunk_size] + chunk_ids = ids[i: i + embedding_chunk_size] + chunk_metadatas = metadatas[i: i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) async_res = [ @@ -175,7 +190,8 @@ def similarity_search_with_score( query: str, k: int = 4, ) -> List[Tuple[Document, float]]: - """Retrieve texts most similar to query and convert the result to `Document` objects. + """Retrieve texts most similar to query and + convert the result to `Document` objects. Args: query: Text to look up documents similar to. @@ -210,7 +226,8 @@ def similarity_search_by_vector_with_score( if metadata and self._text_key in metadata: text = metadata.pop(self._text_key) score = res.score - docs.append((Document(page_content=text, metadata=metadata), score)) + docs.append( + (Document(page_content=text, metadata=metadata), score)) else: logger.warning( f"Found document with no `{self._text_key}` key. Skipping." @@ -233,7 +250,8 @@ def similarity_search( Returns: List of Documents most similar to the query and score for each """ - docs_and_scores = self.similarity_search_with_score(query, k=k, **kwargs) + docs_and_scores = self.similarity_search_with_score( + query, k=k, **kwargs) return [doc for doc, _ in docs_and_scores] def max_marginal_relevance_search_by_vector( @@ -275,7 +293,9 @@ def max_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + # type: ignore since include_metadata=True + Document(page_content=metadata.pop( + (self._text_key)), metadata=metadata) for metadata in selected ] @@ -362,14 +382,15 @@ def delete( Args: ids: List of ids to delete. delete_all: Delete all vectors in the index. - batch_size: Batch size to use when deleting the embeddings. Upstash supports at max 1000 deletions per request. + batch_size: Batch size to use when deleting the embeddings. + Upstash supports at max 1000 deletions per request. """ if delete_all: self._index.reset() elif ids is not None: for i in range(0, len(ids), batch_size): - chunk = ids[i : i + batch_size] + chunk = ids[i: i + batch_size] self._index.delete(ids=chunk) else: raise ValueError("Either ids or delete_all should be provided") From 4b7ed74b1bec3a2b51edd5c6f6d60435ff76b07d Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 11:20:55 +0300 Subject: [PATCH 07/41] Add example env vars --- libs/community/tests/integration_tests/.env.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/community/tests/integration_tests/.env.example b/libs/community/tests/integration_tests/.env.example index 99be838353376..6effabe6afabb 100644 --- a/libs/community/tests/integration_tests/.env.example +++ b/libs/community/tests/integration_tests/.env.example @@ -50,3 +50,7 @@ POWERBI_NUMROWS=_num_rows_in_your_test_table # MongoDB Atlas Vector Search MONGODB_ATLAS_URI=your_mongodb_atlas_connection_string + +# Upstash Vector +UPSTASH_VECTOR_URL=your_upstash_vector_url +UPSTASH_VECTOR_TOKEN=your_upstash_vector_token From 0d42775b49b8a6b766e08a636693bfa70ac16e53 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 15:21:58 +0300 Subject: [PATCH 08/41] Fix iteration --- .../vectorstores/upstash.py | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 5760507e005e5..7726292fe727d 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -159,27 +159,17 @@ def add_texts( for metadata, text in zip(metadatas, texts): metadata[self._text_key] = text - # For loops to avoid memory issues and optimize when using HTTP based embeddings - # The first loop runs the embeddings, it benefits when using OpenAI embeddings - # The second loops runs the pinecone upsert asynchronously. for i in range(0, len(texts), embedding_chunk_size): chunk_texts = texts[i: i + embedding_chunk_size] chunk_ids = ids[i: i + embedding_chunk_size] chunk_metadatas = metadatas[i: i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) - async_res = [ - self._index.upsert( - vectors=batch, - **kwargs, - ) + async def upsert_all(): for batch in batch_iterate( batch_size, zip(chunk_ids, embeddings, chunk_metadatas) - ) - ] - - async def upsert_all(): - return await asyncio.gather(*async_res) + ): + await self._index.upsert(vectors=batch) asyncio.run(upsert_all()) @@ -293,9 +283,8 @@ def max_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - # type: ignore since include_metadata=True Document(page_content=metadata.pop( - (self._text_key)), metadata=metadata) + (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True for metadata in selected ] @@ -389,9 +378,8 @@ def delete( if delete_all: self._index.reset() elif ids is not None: - for i in range(0, len(ids), batch_size): - chunk = ids[i: i + batch_size] - self._index.delete(ids=chunk) + for batch in batch_iterate(batch_size, ids): + self._index.delete(ids=batch) else: raise ValueError("Either ids or delete_all should be provided") From 894d9a1421fcfa8b0c37ba18e335715416ed94e0 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 15:50:58 +0300 Subject: [PATCH 09/41] Add env vars to scheduled tests workflow file --- .github/workflows/scheduled_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/scheduled_test.yml b/.github/workflows/scheduled_test.yml index 4ae8b755c146c..877a4b712cc46 100644 --- a/.github/workflows/scheduled_test.yml +++ b/.github/workflows/scheduled_test.yml @@ -66,6 +66,8 @@ jobs: AZURE_OPENAI_LLM_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LLM_DEPLOYMENT_NAME }} AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME }} FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }} + UPSTASH_VECTOR_URL: ${{ secrets.UPSTASH_VECTOR_URL }} + UPSTASH_VECTOR_TOKEN: ${{ secrets.UPSTASH_VECTOR_TOKEN }} run: | make scheduled_tests From 2e507794b24f31705c69384a520500178d841f9d Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 15:56:30 +0300 Subject: [PATCH 10/41] Formatting --- .../vectorstores/test_upstash.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 632f4b1e0f82d..9869ef5d918e2 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -23,7 +23,8 @@ def is_api_accessible(url: str) -> bool: def test_upstash() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings()) output = docsearch.similarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -31,7 +32,8 @@ def test_upstash() -> None: async def test_upstash_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings()) output = await docsearch.asimilarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -59,7 +61,8 @@ def test_upstash_with_metadatas_with_scores() -> None: metadatas=metadatas, ) output = docsearch.similarity_search_with_score("foo", k=1) - assert output == [(Document(page_content="foo", metadata={"page": "0"}), 0.0)] + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 0.0)] def test_upstash_with_metadatas_with_scores_using_vector() -> None: @@ -77,13 +80,15 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: output = docsearch.similarity_search_by_vector_with_score( embedding=embedded_query, k=1 ) - assert output == [(Document(page_content="foo", metadata={"page": "0"}), 0.0)] + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 0.0)] def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings()) output = docsearch.max_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -92,9 +97,11 @@ def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] embeddings = FakeEmbeddings() - docsearch = UpstashVectorStore.from_texts(texts=texts, embedding=embeddings) + docsearch = UpstashVectorStore.from_texts( + texts=texts, embedding=embeddings) embedded_query = embeddings.embed_query("foo") - output = docsearch.max_marginal_relevance_search_by_vector(embedded_query, k=1) + output = docsearch.max_marginal_relevance_search_by_vector( + embedded_query, k=1) assert output == [Document(page_content="foo")] From 6a8ed635f59f2db9f3e271e0e41e8b9af8880b12 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Mon, 5 Feb 2024 15:56:38 +0300 Subject: [PATCH 11/41] Remove skip --- .../tests/integration_tests/vectorstores/test_upstash.py | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 9869ef5d918e2..86bebd2c1220d 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -132,7 +132,6 @@ def test_init_from_client() -> None: assert store.info() is not None -@pytest.skip() def test_init_from_credentials() -> None: store = UpstashVectorStore( index_url=os.environ["UPSTASH_VECTOR_URL"], From 6518ae78d08b0eba2263f52d75d9787e027d4558 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Thu, 8 Feb 2024 01:27:59 +0300 Subject: [PATCH 12/41] Add async implementations of functions --- .../vectorstores/upstash.py | 281 +++++++++++++++--- 1 file changed, 242 insertions(+), 39 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 7726292fe727d..879da0c3cc1cc 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -1,9 +1,8 @@ from __future__ import annotations -import asyncio import logging import uuid -from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple +from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple import numpy as np from langchain_core.documents import Document @@ -16,7 +15,7 @@ ) if TYPE_CHECKING: - from upstash_vector import AsyncIndex + from upstash_vector import AsyncIndex, Index logger = logging.getLogger(__name__) @@ -45,7 +44,8 @@ class UpstashVectorStore(VectorStore): def __init__( self, text_key: Optional[str] = "text", - index: Optional[AsyncIndex] = None, + index: Optional[Index] = None, + async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, index_token: Optional[str] = None, embedding: Optional[Embeddings] = None, @@ -59,7 +59,9 @@ def __init__( Args: text_key: Key to store the text in metadata. - index: UpstashVector AsyncIndex object. + index: UpstashVector Index object. + async_index: UpstashVector AsyncIndex object, provide only if async + functions are needed index_url: URL of the UpstashVector index. index_token: Token of the UpstashVector index. embedding: Embeddings object. @@ -76,10 +78,19 @@ def __init__( index_url="...", index_token="..." ) + + # With an existing index + from upstash_vector import Index + + index = Index(url="...", token="...") + vectorstore = UpstashVectorStore( + embedding=embeddings, + index=index + ) """ try: - from upstash_vector import AsyncIndex + from upstash_vector import AsyncIndex, Index except ImportError: raise ImportError( "Could not import upstash_vector python package. " @@ -87,20 +98,32 @@ def __init__( ) if index: - if not isinstance(index, AsyncIndex): + if not isinstance(index, Index): raise ValueError( "Passed index object should be an " - "instance of upstash_vector.AsyncIndex, " + "instance of upstash_vector.Index, " f"got {type(index)}" ) self._index = index logger.info("Using the index passed as parameter") - elif index_url and index_token: - self._index = AsyncIndex(url=index_url, token=index_token) + if async_index: + if not isinstance(async_index, Index): + raise ValueError( + "Passed index object should be an " + "instance of upstash_vector.AsyncIndex, " + f"got {type(async_index)}" + ) + self._async_index = async_index + logger.info("Using the async index passed as parameter") + + if index_url and index_token: + self._index = Index(url=index_url, token=index_token) + self._async_index = AsyncIndex(url=index_url, token=index_token) logger.info( "Created index from the index_url and index_token parameters") - else: - self._index = AsyncIndex.from_env() + elif not index and not async_index: + self._index = Index.from_env() + self._async_index = AsyncIndex.from_env() logger.info("Created index using environment variables") self._embeddings = embedding @@ -126,7 +149,6 @@ def add_texts( ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, - **kwargs: Any, ) -> List[str]: """ Get the embeddings for the texts and add them to the vectorstore. @@ -165,13 +187,10 @@ def add_texts( chunk_metadatas = metadatas[i: i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) - async def upsert_all(): - for batch in batch_iterate( - batch_size, zip(chunk_ids, embeddings, chunk_metadatas) - ): - await self._index.upsert(vectors=batch) - - asyncio.run(upsert_all()) + for batch in batch_iterate( + batch_size, zip(chunk_ids, embeddings, chunk_metadatas) + ): + self._index.upsert(vectors=batch) return ids @@ -186,7 +205,6 @@ def similarity_search_with_score( Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. - filter: Dictionary of argument(s) to filter on metadata Returns: List of Documents most similar to the query and score for each @@ -195,22 +213,66 @@ def similarity_search_with_score( self._embed_query(query), k=k ) + async def asimilarity_search_with_score( + self, + query: str, + k: int = 4, + ) -> List[Tuple[Document, float]]: + """Retrieve texts most similar to query and + convert the result to `Document` objects. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + + Returns: + List of Documents most similar to the query and score for each + """ + return await self.asimilarity_search_by_vector_with_score( + self._embed_query(query), k=k + ) + def similarity_search_by_vector_with_score( self, embedding: List[float], - *, k: int = 4, ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" docs = [] - results = asyncio.run( - self._index.query( - vector=embedding, - top_k=k, - include_metadata=True, - ) + results = self._index.query( + vector=embedding, + top_k=k, + include_metadata=True, + ) + + for res in results: + metadata = res.metadata + if metadata and self._text_key in metadata: + text = metadata.pop(self._text_key) + score = res.score + docs.append( + (Document(page_content=text, metadata=metadata), score)) + else: + logger.warning( + f"Found document with no `{self._text_key}` key. Skipping." + ) + return docs + + async def asimilarity_search_by_vector_with_score( + self, + embedding: List[float], + k: int = 4, + ) -> List[Tuple[Document, float]]: + """Return texts whose embedding is closest to the given embedding""" + + docs = [] + results = await self._async_index.query( + vector=embedding, + top_k=k, + include_metadata=True, ) + for res in results: metadata = res.metadata if metadata and self._text_key in metadata: @@ -228,20 +290,66 @@ def similarity_search( self, query: str, k: int = 4, - **kwargs: Any, ) -> List[Document]: """Return documents most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. - filter: Dictionary of argument(s) to filter on metadata Returns: List of Documents most similar to the query and score for each """ docs_and_scores = self.similarity_search_with_score( - query, k=k, **kwargs) + query, k=k) + return [doc for doc, _ in docs_and_scores] + + async def asimilarity_search( + self, + query: str, + k: int = 4, + ) -> List[Document]: + """Return documents most similar to query. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + + Returns: + List of Documents most similar to the query + """ + docs_and_scores = await self.asimilarity_search_with_score( + query, k=k) + return [doc for doc, _ in docs_and_scores] + + def similarity_search_by_vector( + self, embedding: List[float], k: int = 4) -> List[Document]: + """Return documents closest to the given embedding. + + Args: + embedding: Embedding to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + + Returns: + List of Documents most similar to the query + """ + docs_and_scores = self.similarity_search_by_vector_with_score( + embedding, k=k) + return [doc for doc, _ in docs_and_scores] + + async def asimilarity_search_by_vector( + self, embedding: List[float], k: int = 4) -> List[Document]: + """Return documents closest to the given embedding. + + Args: + embedding: Embedding to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + + Returns: + List of Documents most similar to the query + """ + docs_and_scores = await self.asimilarity_search_by_vector_with_score( + embedding, k=k) return [doc for doc, _ in docs_and_scores] def max_marginal_relevance_search_by_vector( @@ -267,13 +375,53 @@ def max_marginal_relevance_search_by_vector( Returns: List of Documents selected by maximal marginal relevance. """ - results = asyncio.run( - self._index.query( - vector=embedding, - top_k=fetch_k, - include_vectors=True, - include_metadata=True, - ) + results = self._index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + ) + mmr_selected = maximal_marginal_relevance( + np.array([embedding], dtype=np.float32), + [item.vector for item in results], + k=k, + lambda_mult=lambda_mult, + ) + selected = [results[i].metadata for i in mmr_selected] + return [ + Document(page_content=metadata.pop( + (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + for metadata in selected + ] + + async def amax_marginal_relevance_search_by_vector( + self, + embedding: List[float], + k: int = 4, + fetch_k: int = 20, + lambda_mult: float = 0.5, + ) -> List[Document]: + """Return docs selected using the maximal marginal relevance. + + Maximal marginal relevance optimizes for similarity to query AND diversity + among selected documents. + + Args: + embedding: Embedding to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + fetch_k: Number of Documents to fetch to pass to MMR algorithm. + lambda_mult: Number between 0 and 1 that determines the degree + of diversity among the results with 0 corresponding + to maximum diversity and 1 to minimum diversity. + Defaults to 0.5. + Returns: + List of Documents selected by maximal marginal relevance. + """ + results = await self._async_index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), @@ -316,6 +464,34 @@ def max_marginal_relevance_search( embedding=embedding, k=k, fetch_k=fetch_k, lambda_mult=lambda_mult ) + async def amax_marginal_relevance_search( + self, + query: str, + k: int = 4, + fetch_k: int = 20, + lambda_mult: float = 0.5, + ) -> List[Document]: + """Return docs selected using the maximal marginal relevance. + + Maximal marginal relevance optimizes for similarity to query AND diversity + among selected documents. + + Args: + query: Text to look up documents similar to. + k: Number of Documents to return. Defaults to 4. + fetch_k: Number of Documents to fetch to pass to MMR algorithm. + lambda_mult: Number between 0 and 1 that determines the degree + of diversity among the results with 0 corresponding + to maximum diversity and 1 to minimum diversity. + Defaults to 0.5. + Returns: + List of Documents selected by maximal marginal relevance. + """ + embedding = self._embed_query(query) + return await self.amax_marginal_relevance_search_by_vector( + embedding=embedding, k=k, fetch_k=fetch_k, lambda_mult=lambda_mult + ) + @classmethod def from_texts( cls, @@ -326,7 +502,8 @@ def from_texts( embedding_chunk_size: int = 1000, batch_size: int = 32, text_key: str = "text", - index: Optional[AsyncIndex] = None, + index: Optional[Index] = None, + async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, index_token: Optional[str] = None, ) -> UpstashVectorStore: @@ -347,6 +524,7 @@ def from_texts( embedding=embedding, text_key=text_key, index=index, + async_index=async_index, index_url=index_url, index_token=index_token, ) @@ -385,6 +563,31 @@ def delete( return None + async def adelete( + self, + ids: Optional[List[str]] = None, + delete_all: Optional[bool] = None, + batch_size=1000, + ) -> None: + """Delete by vector IDs + + Args: + ids: List of ids to delete. + delete_all: Delete all vectors in the index. + batch_size: Batch size to use when deleting the embeddings. + Upstash supports at max 1000 deletions per request. + """ + + if delete_all: + await self._async_index.reset() + elif ids is not None: + for batch in batch_iterate(batch_size, ids): + await self._async_index.delete(ids=batch) + else: + raise ValueError("Either ids or delete_all should be provided") + + return None + def info(self): """Get statistics about the index. From 4d7dfefa977f96eea5bda2cb163762ac0a9b0c3d Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Thu, 8 Feb 2024 16:00:49 +0300 Subject: [PATCH 13/41] Remove upstash keys from yaml file --- .github/workflows/scheduled_test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/scheduled_test.yml b/.github/workflows/scheduled_test.yml index 877a4b712cc46..4ae8b755c146c 100644 --- a/.github/workflows/scheduled_test.yml +++ b/.github/workflows/scheduled_test.yml @@ -66,8 +66,6 @@ jobs: AZURE_OPENAI_LLM_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LLM_DEPLOYMENT_NAME }} AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME }} FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }} - UPSTASH_VECTOR_URL: ${{ secrets.UPSTASH_VECTOR_URL }} - UPSTASH_VECTOR_TOKEN: ${{ secrets.UPSTASH_VECTOR_TOKEN }} run: | make scheduled_tests From 3586defae3b1ff513d3f8d623f5ca690a7ae1592 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Fri, 9 Feb 2024 16:08:53 +0300 Subject: [PATCH 14/41] Fixes, finalize integration tests --- .../vectorstores/upstash.py | 32 ++++++++- .../vectorstores/test_upstash.py | 68 ++++++++++++------- 2 files changed, 73 insertions(+), 27 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 879da0c3cc1cc..473c04ec65b2b 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -107,7 +107,7 @@ def __init__( self._index = index logger.info("Using the index passed as parameter") if async_index: - if not isinstance(async_index, Index): + if not isinstance(async_index, AsyncIndex): raise ValueError( "Passed index object should be an " "instance of upstash_vector.AsyncIndex, " @@ -136,10 +136,18 @@ def embeddings(self) -> Optional[Embeddings]: def _embed_documents(self, texts: Iterable[str]) -> List[List[float]]: """Embed strings using the embeddings object""" + if not self._embeddings: + raise ValueError( + "No embeddings object provided. " + "Pass an embeddings object to the constructor.") return self._embeddings.embed_documents(list(texts)) def _embed_query(self, text: str) -> List[float]: """Embed query text using the embeddings object.""" + if not self._embeddings: + raise ValueError( + "No embeddings object provided. " + "Pass an embeddings object to the constructor.") return self._embeddings.embed_query(text) def add_texts( @@ -175,7 +183,12 @@ def add_texts( """ texts = list(texts) ids = ids or [str(uuid.uuid4()) for _ in texts] - metadatas = metadatas or [{} for _ in texts] + + # Copy metadatas to avoid modifying the original documents + if metadatas: + metadatas = [m.copy() for m in metadatas] + else: + metadatas = [{} for _ in texts] # Add text to metadata for metadata, text in zip(metadatas, texts): @@ -246,11 +259,14 @@ def similarity_search_by_vector_with_score( include_metadata=True, ) + print(f"results from querying for {embedding}:", results) + for res in results: metadata = res.metadata if metadata and self._text_key in metadata: text = metadata.pop(self._text_key) score = res.score + print("metadata:", metadata) docs.append( (Document(page_content=text, metadata=metadata), score)) else: @@ -599,3 +615,15 @@ def info(self): - similarity function selected for the index """ return self._index.info() + + async def ainfo(self): + """Get statistics about the index. + + Returns: + - total number of vectors + - total number of vectors waiting to be indexed + - total size of the index on disk in bytes + - dimension count for the index + - similarity function selected for the index + """ + return await self._async_index.info() diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 86bebd2c1220d..f257493fd4ece 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -1,17 +1,31 @@ """Test Upstash Vector functionality.""" import os +from time import sleep import pytest import requests from langchain_core.documents import Document +from upstash_vector import Index, AsyncIndex from langchain_community.vectorstores.upstash import UpstashVectorStore from tests.integration_tests.vectorstores.fake_embeddings import ( FakeEmbeddings, ) +@pytest.fixture(scope='function', autouse=True) +def fixture(): + index = Index.from_env() + index.reset() + wait_for_indexing() + + +def wait_for_indexing(): + # Wait for indexing to complete + sleep(1) + + def is_api_accessible(url: str) -> bool: try: response = requests.get(url) @@ -25,15 +39,18 @@ def test_upstash() -> None: texts = ["foo", "bar", "baz"] docsearch = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) + wait_for_indexing() output = docsearch.similarity_search("foo", k=1) assert output == [Document(page_content="foo")] +@pytest.mark.asyncio async def test_upstash_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] docsearch = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) + wait_for_indexing() output = await docsearch.asimilarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -47,6 +64,7 @@ def test_upstash_with_metadatas() -> None: embedding=FakeEmbeddings(), metadatas=metadatas, ) + wait_for_indexing() output = docsearch.similarity_search("foo", k=1) assert output == [Document(page_content="foo", metadata={"page": "0"})] @@ -60,9 +78,10 @@ def test_upstash_with_metadatas_with_scores() -> None: embedding=FakeEmbeddings(), metadatas=metadatas, ) + wait_for_indexing() output = docsearch.similarity_search_with_score("foo", k=1) assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + (Document(page_content="foo", metadata={"page": "0"}), 1.0)] def test_upstash_with_metadatas_with_scores_using_vector() -> None: @@ -76,12 +95,13 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: embedding=embeddings, metadatas=metadatas, ) + wait_for_indexing() embedded_query = embeddings.embed_query("foo") output = docsearch.similarity_search_by_vector_with_score( embedding=embedded_query, k=1 ) assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 0.0)] + (Document(page_content="foo", metadata={"page": "0"}), 1.0)] def test_upstash_mmr() -> None: @@ -89,6 +109,7 @@ def test_upstash_mmr() -> None: texts = ["foo", "bar", "baz"] docsearch = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) + wait_for_indexing() output = docsearch.max_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -99,51 +120,46 @@ def test_upstash_mmr_by_vector() -> None: embeddings = FakeEmbeddings() docsearch = UpstashVectorStore.from_texts( texts=texts, embedding=embeddings) + wait_for_indexing() embedded_query = embeddings.embed_query("foo") output = docsearch.max_marginal_relevance_search_by_vector( embedded_query, k=1) assert output == [Document(page_content="foo")] -def test_upstash_with_relevance_score() -> None: - """Test to make sure the relevance score is scaled to 0-1.""" - texts = ["foo", "bar", "baz"] - metadatas = [{"page": str(i)} for i in range(len(texts))] - docsearch = UpstashVectorStore.from_texts( - texts=texts, - embedding=FakeEmbeddings(), - metadatas=metadatas, - ) - output = docsearch.similarity_search_with_relevance_scores("foo", k=3) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 1.0), - (Document(page_content="bar", metadata={"page": "1"}), 0.8), - (Document(page_content="baz", metadata={"page": "2"}), 0.5), - ] +def test_init_from_index() -> None: + index = Index.from_env() + + store = UpstashVectorStore(index=index) + assert store.info() is not None -def test_init_from_client() -> None: - from upstash_vector import AsyncIndex +def test_init_from_async_index() -> None: index = AsyncIndex.from_env() - store = UpstashVectorStore(index=index) + store = UpstashVectorStore(async_index=index) - assert store.info() is not None + assert store.ainfo() is not None -def test_init_from_credentials() -> None: +@pytest.mark.asyncio +async def test_init_from_credentials() -> None: store = UpstashVectorStore( - index_url=os.environ["UPSTASH_VECTOR_URL"], - index_token=os.environ["UPSTASH_VECTOR_TOKEN"], + index_url=os.environ["UPSTASH_VECTOR_REST_URL"], + index_token=os.environ["UPSTASH_VECTOR_REST_TOKEN"], ) - assert store.info() is not None + assert await store.ainfo() is not None def test_upstash_add_documents_no_metadata() -> None: db = UpstashVectorStore(embedding=FakeEmbeddings()) db.add_documents([Document(page_content="foo")]) + wait_for_indexing() + + search = db.similarity_search("foo") + assert search == [Document(page_content="foo")] def test_upstash_add_documents_mixed_metadata() -> None: @@ -152,8 +168,10 @@ def test_upstash_add_documents_mixed_metadata() -> None: Document(page_content="foo"), Document(page_content="bar", metadata={"baz": 1}), ] + print("og docs", docs) ids = ["0", "1"] actual_ids = db.add_documents(docs, ids=ids) + wait_for_indexing() assert actual_ids == ids search = db.similarity_search("foo bar") assert sorted(search, key=lambda d: d.page_content) == sorted( From 7d32e020793e5c67f03cfe38b1fdff8bd19b9399 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Tue, 13 Feb 2024 11:47:00 +0300 Subject: [PATCH 15/41] Remove optional from text_key in constructor --- libs/community/langchain_community/vectorstores/upstash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 473c04ec65b2b..94f63266c8031 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -43,7 +43,7 @@ class UpstashVectorStore(VectorStore): def __init__( self, - text_key: Optional[str] = "text", + text_key: str = "text", index: Optional[Index] = None, async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, From 7be8f62c246888ef6aa205819f91f1a9b1ee77c0 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Fri, 16 Feb 2024 09:28:55 +0300 Subject: [PATCH 16/41] Remove forgotten print --- libs/community/langchain_community/vectorstores/upstash.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 94f63266c8031..ec075af2b76fb 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -259,14 +259,11 @@ def similarity_search_by_vector_with_score( include_metadata=True, ) - print(f"results from querying for {embedding}:", results) - for res in results: metadata = res.metadata if metadata and self._text_key in metadata: text = metadata.pop(self._text_key) score = res.score - print("metadata:", metadata) docs.append( (Document(page_content=text, metadata=metadata), score)) else: From 9d94e98b9b7b4c2de34e9df5184d76672e995baf Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Fri, 16 Feb 2024 10:55:00 +0300 Subject: [PATCH 17/41] Add upstash docs notebook --- .../integrations/vectorstores/upstash.ipynb | 417 ++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 docs/docs/integrations/vectorstores/upstash.ipynb diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb new file mode 100644 index 0000000000000..461bc3f67367f --- /dev/null +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -0,0 +1,417 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Upstash Vector\n", + "\n", + "[Upstash Vector](https://upstash.com/docs/vector/overall/whatisvector) is a serverless vector database designed for working with vector embeddings.\n", + "\n", + "The vector langchain integration is a wrapper around the [upstash-vector](https://github.com/upstash/vector-py) package.\n", + "\n", + "The python package uses the [vector rest api](https://upstash.com/docs/vector/api/get-started) behind the scenes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Installation\n", + "\n", + "Create a free vector database from [upstash console](https://console.upstash.com/vector) with the desired dimensions and distance metric.\n", + "\n", + "You can then create an `UpstashVectorStore` instance by:\n", + "\n", + "- Providing the environment variables `UPSTASH_VECTOR_URL` and `UPSTASH_VECTOR_TOKEN`\n", + "\n", + "- Giving them as parameters to the constructor\n", + "\n", + "- Passing an Upstash Vector `Index` instance to the constructor\n", + "\n", + "Also, an `Embeddings` instance is required to turn given texts into embeddings. Here we use `OpenAIEmbeddings` as an example" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: langchain-openai in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.0.6)\n", + "Requirement already satisfied: langchain in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.1.3)\n", + "Requirement already satisfied: upstash-vector in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.2.0)\n", + "Requirement already satisfied: langchain-core<0.2,>=0.1.16 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (0.1.23)\n", + "Requirement already satisfied: numpy<2,>=1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (1.23.5)\n", + "Requirement already satisfied: openai<2.0.0,>=1.10.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (1.12.0)\n", + "Requirement already satisfied: tiktoken<1,>=0.5.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (0.5.2)\n", + "Requirement already satisfied: PyYAML>=5.3 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (6.0)\n", + "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.0.25)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (3.9.1)\n", + "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.6.3)\n", + "Requirement already satisfied: jsonpatch<2.0,>=1.33 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (1.33)\n", + "Requirement already satisfied: langchain-community<0.1,>=0.0.14 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.0.15)\n", + "Requirement already satisfied: langsmith<0.1,>=0.0.83 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.0.87)\n", + "Requirement already satisfied: pydantic<3,>=1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.5.3)\n", + "Requirement already satisfied: requests<3,>=2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.31.0)\n", + "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (8.2.3)\n", + "Requirement already satisfied: httpx<0.26.0,>=0.25.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from upstash-vector) (0.25.2)\n", + "Requirement already satisfied: attrs>=17.3.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (22.1.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.2)\n", + "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.8.1)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.3)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.2.0)\n", + "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (3.20.2)\n", + "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (0.9.0)\n", + "Requirement already satisfied: anyio in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (3.5.0)\n", + "Requirement already satisfied: certifi in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (2023.7.22)\n", + "Requirement already satisfied: httpcore==1.* in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (1.0.2)\n", + "Requirement already satisfied: idna in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (3.4)\n", + "Requirement already satisfied: sniffio in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (1.2.0)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpcore==1.*->httpx<0.26.0,>=0.25.0->upstash-vector) (0.14.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from jsonpatch<2.0,>=1.33->langchain) (2.4)\n", + "Requirement already satisfied: packaging<24.0,>=23.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-core<0.2,>=0.1.16->langchain-openai) (23.2)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (1.9.0)\n", + "Requirement already satisfied: tqdm>4 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.66.1)\n", + "Requirement already satisfied: typing-extensions<5,>=4.7 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.7.1)\n", + "Requirement already satisfied: annotated-types>=0.4.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from pydantic<3,>=1->langchain) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.14.6 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from pydantic<3,>=1->langchain) (2.14.6)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from requests<3,>=2->langchain) (2.0.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from requests<3,>=2->langchain) (1.26.16)\n", + "Requirement already satisfied: regex>=2022.1.18 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from tiktoken<1,>=0.5.2->langchain-openai) (2023.12.25)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain) (1.0.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install langchain-openai langchain upstash-vector" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# from langchain_community.vectorstores.upstash import UpstashVectorStore\n", + "from langchain_openai import OpenAIEmbeddings\n", + "\n", + "# TODO: Delete before push\n", + "from libs.community.langchain_community.vectorstores.upstash import UpstashVectorStore\n", + "from langchain_openai import OpenAIEmbeddings\n", + "\n", + "import os\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = \"\"\n", + "os.environ[\"UPSTASH_VECTOR_URL\"] = \"\"\n", + "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"\"\n", + "\n", + "# TODO: Delete before push\n", + "os.environ[\"OPENAI_API_KEY\"] = \"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\"\n", + "os.environ[\"UPSTASH_VECTOR_URL\"] = \"https://sincere-serval-66939-us1-vector.upstash.io\"\n", + "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"ABgFMHNpbmNlcmUtc2VydmFsLTY2OTM5LXVzMWFkbWluWVdVMk56bGtOV010WkRVNVl5MDBOR0kwTFdKaE5HVXRNRFkyTldGalpqa3lZV1Zq\"\n", + "\n", + "# Create an embeddings instance\n", + "embeddings = OpenAIEmbeddings()\n", + "\n", + "# Create a vector store instance\n", + "store = UpstashVectorStore(\n", + " embedding=embeddings\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load documents\n", + "\n", + "Load an example text file and split it into chunks which can be turned into vector embeddings." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='Putin’s latest attack on Ukraine was premeditated and unprovoked. \\n\\nHe rejected repeated efforts at diplomacy. \\n\\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \\n\\nWe prepared extensively and carefully. \\n\\nWe spent months building a coalition of other freedom-loving nations from Europe and the Americas to Asia and Africa to confront Putin. \\n\\nI spent countless hours unifying our European allies. We shared with the world in advance what we knew Putin was planning and precisely how he would try to falsely justify his aggression. \\n\\nWe countered Russia’s lies with truth. \\n\\nAnd now that he has acted the free world is holding him accountable. \\n\\nAlong with twenty-seven members of the European Union including France, Germany, Italy, as well as countries like the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzerland.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'})]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from langchain.text_splitter import CharacterTextSplitter\n", + "from langchain_community.document_loaders import TextLoader\n", + "from langchain_openai import OpenAIEmbeddings\n", + "\n", + "# TODO: Delete before push\n", + "loader = TextLoader(\"docs/docs/modules/state_of_the_union.txt\")\n", + "\n", + "# loader = TextLoader(\"../../modules/state_of_the_union.txt\")\n", + "documents = loader.load()\n", + "text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)\n", + "docs = text_splitter.split_documents(documents)\n", + "\n", + "docs[:3]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Inserting documents\n", + "\n", + "The vectorstore embeds text chunks using the embedding object and batch inserts them into the database. This returns an id array of the inserted vectors." + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['95362512-0801-4b33-8e32-91ed563b25e5',\n", + " '7ee0cb06-0987-4d31-9089-c5b6c42fea08',\n", + " '40abd35c-e687-476c-a426-fcbb1fd679d8',\n", + " '4450d872-56b0-49a2-aa91-a5a718815bec',\n", + " '00a6df29-621b-4a48-a7d7-9a81ca4030de']" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inserted_vectors = store.add_documents(docs)\n", + "\n", + "inserted_vectors[:5]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "store" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['6010f8ef-ee75-4c37-8db8-052431a8bd01',\n", + " 'a388f11a-7cc3-4878-a8ac-77ba7c47fb82']" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "store.add_texts([\"This is a test\", \"This is another test\"],\n", + " [{\n", + " \"title\": \"Test 1\",\n", + " \"author\": \"John Doe\",\n", + " \"date\": \"2021-01-01\"\n", + " },\n", + " {\n", + " \"title\": \"Test 2\",\n", + " \"author\": \"Jane Doe\",\n", + " \"date\": \"2021-01-02\"\n", + " }])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Querying\n", + "\n", + "The database can be queried using a vector or a text prompt.\n", + "If a text prompt is used, it's first converted into embedding and then queried.\n", + "\n", + "The `k` parameter specifies how many results to return from the query." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[Document(page_content='And my report is this: the State of the Union is strong—because you, the American people, are strong. \\n\\nWe are stronger today than we were a year ago. \\n\\nAnd we will be stronger a year from now than we are today. \\n\\nNow is our moment to meet and overcome the challenges of our time. \\n\\nAnd we will, as one people. \\n\\nOne America. \\n\\nThe United States of America. \\n\\nMay God bless you all. May God protect our troops.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='And built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation. \\n\\nWe will meet the test. \\n\\nTo protect freedom and liberty, to expand fairness and opportunity. \\n\\nWe will save democracy. \\n\\nAs hard as these times have been, I am more optimistic about America today than I have been my whole life. \\n\\nBecause I see the future that is within our grasp. \\n\\nBecause I know there is simply nothing beyond our capacity. \\n\\nWe are the only nation on Earth that has always turned every crisis we have faced into an opportunity. \\n\\nThe only nation that can be defined by a single word: possibilities. \\n\\nSo on this night, in our 245th year as a nation, I have come to report on the State of the Union.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", + " Document(page_content='For that purpose we’ve mobilized American ground forces, air squadrons, and ship deployments to protect NATO countries including Poland, Romania, Latvia, Lithuania, and Estonia. \\n\\nAs I have made crystal clear the United States and our Allies will defend every inch of territory of NATO countries with the full force of our collective power. \\n\\nAnd we remain clear-eyed. The Ukrainians are fighting back with pure courage. But the next few days weeks, months, will be hard on them. \\n\\nPutin has unleashed violence and chaos. But while he may make gains on the battlefield – he will pay a continuing high price over the long run. \\n\\nAnd a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'})]" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result = store.similarity_search(\n", + " \"The United States of America\",\n", + " k=5\n", + ")\n", + "result" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Querying with score\n", + "\n", + "The score of the query can be included for every result. \n", + "\n", + "> The score returned in the query requests is a normalized value between 0 and 1, where 1 indicates the highest similarity and 0 the lowest regardless of the similarity function used. For more information look at the [docs](https://upstash.com/docs/vector/overall/features#vector-similarity-functions)." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9181416\n", + "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.91668516\n", + "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9117657\n", + "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.90447474\n", + "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9022917\n" + ] + } + ], + "source": [ + "result = store.similarity_search_with_score(\n", + " \"The United States of America\",\n", + " k=5,\n", + ")\n", + "\n", + "for doc, score in result:\n", + " print(f\"{doc.metadata} - {score}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Deleting vectors\n", + "\n", + "Vectors can be deleted by their ids" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [], + "source": [ + "store.delete(inserted_vectors)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Clearing the vector database\n", + "\n", + "This will clear the vector database" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "store.delete(delete_all=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Getting info about vector database\n", + "\n", + "You can get information about your database like the distance metric dimension using the info function.\n", + "\n", + "> When an insert happens, the database an indexing takes place. While this is happening new vectors can not be queried. `pendingVectorCount` represents the number of vector that are currently being indexed. " + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'vectorCount': 44, 'pendingVectorCount': 0, 'indexSize': 2642412, 'dimension': 1536, 'similarityFunction': 'COSINE'}\n" + ] + }, + { + "data": { + "text/plain": [ + "InfoResult(vector_count=44, pending_vector_count=0, index_size=2642412, dimension=1536, similarity_function='COSINE')" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "store.info()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ai", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 122691655eaec118da235d19e28f75aea9fc0637 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 17:02:48 +0300 Subject: [PATCH 18/41] Add async version of add_texts --- .../vectorstores/upstash.py | 125 +++++++++++++++++- 1 file changed, 122 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index ec075af2b76fb..bfe6d158bd982 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -150,6 +150,74 @@ def _embed_query(self, text: str) -> List[float]: "Pass an embeddings object to the constructor.") return self._embeddings.embed_query(text) + def add_documents( + self, + documents: Iterable[Document], + batch_size: int = 32, + embedding_chunk_size: int = 1000, + ) -> List[str]: + """ + Get the embeddings for the documents and add them to the vectorstore. + + Documents are sent to the embeddings object + in batches of size `embedding_chunk_size`. + The embeddings are then upserted into the vectorstore + in batches of size `batch_size`. + + Args: + documents: Iterable of Documents to add to the vectorstore. + batch_size: Batch size to use when upserting the embeddings. + Upstash supports at max 1000 vectors per request. + embedding_batch_size: Chunk size to use when embedding the texts. + + Returns: + List of ids from adding the texts into the vectorstore. + + """ + texts = [doc.page_content for doc in documents] + metadatas = [doc.metadata for doc in documents] + + return self.add_texts( + texts, + metadatas=metadatas, + batch_size=batch_size, + embedding_chunk_size=embedding_chunk_size, + ) + + async def aadd_documents( + self, + documents: Iterable[Document], + batch_size: int = 32, + embedding_chunk_size: int = 1000, + ) -> List[str]: + """ + Get the embeddings for the documents and add them to the vectorstore. + + Documents are sent to the embeddings object + in batches of size `embedding_chunk_size`. + The embeddings are then upserted into the vectorstore + in batches of size `batch_size`. + + Args: + documents: Iterable of Documents to add to the vectorstore. + batch_size: Batch size to use when upserting the embeddings. + Upstash supports at max 1000 vectors per request. + embedding_batch_size: Chunk size to use when embedding the texts. + + Returns: + List of ids from adding the texts into the vectorstore. + + """ + texts = [doc.page_content for doc in documents] + metadatas = [doc.metadata for doc in documents] + + return self.aadd_texts( + texts, + metadatas=metadatas, + batch_size=batch_size, + embedding_chunk_size=embedding_chunk_size, + ) + def add_texts( self, texts: Iterable[str], @@ -166,9 +234,6 @@ def add_texts( The embeddings are then upserted into the vectorstore in batches of size `batch_size`. - For OpenAI embeddings use embedding_chunk_size>1000 - and batch_size~64 for best performance. - Args: texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. @@ -207,6 +272,60 @@ def add_texts( return ids + async def aadd_texts( + self, + texts: Iterable[str], + metadatas: Optional[List[dict]] = None, + ids: Optional[List[str]] = None, + batch_size: int = 32, + embedding_chunk_size: int = 1000, + ) -> List[str]: + """ + Get the embeddings for the texts and add them to the vectorstore. + + Texts are sent to the embeddings object + in batches of size `embedding_chunk_size`. + The embeddings are then upserted into the vectorstore + in batches of size `batch_size`. + + Args: + texts: Iterable of strings to add to the vectorstore. + metadatas: Optional list of metadatas associated with the texts. + ids: Optional list of ids to associate with the texts. + batch_size: Batch size to use when upserting the embeddings. + Upstash supports at max 1000 vectors per request. + embedding_batch_size: Chunk size to use when embedding the texts. + + Returns: + List of ids from adding the texts into the vectorstore. + + """ + texts = list(texts) + ids = ids or [str(uuid.uuid4()) for _ in texts] + + # Copy metadatas to avoid modifying the original documents + if metadatas: + metadatas = [m.copy() for m in metadatas] + else: + metadatas = [{} for _ in texts] + + # Add text to metadata + for metadata, text in zip(metadatas, texts): + metadata[self._text_key] = text + + for i in range(0, len(texts), embedding_chunk_size): + chunk_texts = texts[i: i + embedding_chunk_size] + chunk_ids = ids[i: i + embedding_chunk_size] + chunk_metadatas = metadatas[i: i + embedding_chunk_size] + embeddings = self._embed_documents(chunk_texts) + + for batch in batch_iterate( + batch_size, zip(chunk_ids, embeddings, chunk_metadatas) + ): + await self._async_index.upsert(vectors=batch) + + return ids + def similarity_search_with_score( self, query: str, From 1d5c172a3db264ea8bcab36a98454279137b3b38 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 17:03:13 +0300 Subject: [PATCH 19/41] Small cleanup --- .../vectorstores/upstash.py | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index bfe6d158bd982..40d74afde1007 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -364,6 +364,19 @@ async def asimilarity_search_with_score( self._embed_query(query), k=k ) + def _results_to_docs(self, results: List): + docs = [] + for res in results: + metadata = res.metadata + if metadata and self._text_key in metadata: + text = metadata.pop(self._text_key) + docs.append(Document(page_content=text, metadata=metadata)) + else: + logger.warning( + f"Found document with no `{self._text_key}` key. Skipping." + ) + return docs + def similarity_search_by_vector_with_score( self, embedding: List[float], @@ -371,25 +384,13 @@ def similarity_search_by_vector_with_score( ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" - docs = [] results = self._index.query( vector=embedding, top_k=k, include_metadata=True, ) - for res in results: - metadata = res.metadata - if metadata and self._text_key in metadata: - text = metadata.pop(self._text_key) - score = res.score - docs.append( - (Document(page_content=text, metadata=metadata), score)) - else: - logger.warning( - f"Found document with no `{self._text_key}` key. Skipping." - ) - return docs + return self._results_to_docs(results) async def asimilarity_search_by_vector_with_score( self, @@ -398,25 +399,13 @@ async def asimilarity_search_by_vector_with_score( ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" - docs = [] results = await self._async_index.query( vector=embedding, top_k=k, include_metadata=True, ) - for res in results: - metadata = res.metadata - if metadata and self._text_key in metadata: - text = metadata.pop(self._text_key) - score = res.score - docs.append( - (Document(page_content=text, metadata=metadata), score)) - else: - logger.warning( - f"Found document with no `{self._text_key}` key. Skipping." - ) - return docs + return self._results_to_docs(results) def similarity_search( self, From 16a73e03ddc1965f689578805f1cc9e9a4f6e680 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 17:11:28 +0300 Subject: [PATCH 20/41] Update docs --- docs/docs/integrations/providers/upstash.mdx | 129 ++++++++++++++++++- 1 file changed, 126 insertions(+), 3 deletions(-) diff --git a/docs/docs/integrations/providers/upstash.mdx b/docs/docs/integrations/providers/upstash.mdx index ff39b87649708..3ed8508360611 100644 --- a/docs/docs/integrations/providers/upstash.mdx +++ b/docs/docs/integrations/providers/upstash.mdx @@ -1,6 +1,130 @@ -# Upstash Redis +Upstash offers developers serverless databases and messaging +platforms to build powerful applications without having to worry +about the operational complexity of running databases at scale. + +One significant advantage of Upstash is that their databases support HTTP and all of their SDKs use HTTP. +This means that you can run this in serverless platforms, edge or any platform that does not support TCP connections. + +Currently, there are two Upstash integrations available for LangChain: +Upstash Vector as a vector embedding database and Upstash Redis as a cache and memory store. + +# Upstash Vector + +Upstash Vector is a serverless vector database that can be used to store and query vectors. + +## Installation + +Create a new serverless vector database at the [Upstash Console](https://console.upstash.com/vector). +Select your preferred distance metric and dimension count according to your model. + + +Install the Upstash Vector Python SDK with `pip install upstash-vector`. +The Upstash Vector integration in langchain is a wrapper for the Upstash Vector Python SDK. That's why the `upstash-vector` package is required. + +## Integrations + +Create a `UpstashVectorStore` object using credentials from the Upstash Console. +You also need to pass in an `Embeddings` object which can turn text into vector embeddings. + +```python +from langchain_community.vectorstores.upstash import UpstashVectorStore +import os + +os.environ["UPSTASH_VECTOR_REST_URL"] = "" +os.environ["UPSTASH_VECTOR_TOKEN"] = "" + +store = UpstashVectorStore( + embedding=embeddings +) +``` + +### Inserting Vectors + +```python +from langchain.text_splitter import CharacterTextSplitter +from langchain_community.document_loaders import TextLoader +from langchain_openai import OpenAIEmbeddings + +loader = TextLoader("../../modules/state_of_the_union.txt") +documents = loader.load() +text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) +docs = text_splitter.split_documents(documents) + +# Create a new embeddings object +embeddings = OpenAIEmbeddings() + +# Create a new UpstashVectorStore object +store = UpstashVectorStore( + embedding=embeddings +) + +# Insert the document embeddings into the store +store.add_documents(docs) +``` + +When inserting documents, first they are embedded using the `Embeddings` object. + +Most embedding models can embed multiple documents at once, so the documents are batched and embedded in parallel. +The size of the batch can be controlled using the `embedding_chunk_size` parameter. + +The embedded vectors are then stored in the Upstash Vector database. When they are sent, multiple vectors are batched together to reduce the number of HTTP requests. +The size of the batch can be controlled using the `batch_size` parameter. Upstash Vector has a limit of 1000 vectors per batch in the free tier. -Upstash offers developers serverless databases and messaging platforms to build powerful applications without having to worry about the operational complexity of running databases at scale. +```python +store.add_documents( + documents, + batch_size=100, + embedding_chunk_size=200 +) +``` + +### Querying Vectors + +Vectors can be queried using a text query or another vector. + +The returned value is a list of Document objects. + +```python +result = store.similarity_search( + "The United States of America", + k=5 +) +``` + +Or using a vector: + +```python +vector = embeddings.embed_query("Hello world") + +result = store.similarity_search_by_vector( + vector, + k=5 +) +``` + +### Deleting Vectors + +Vectors can be deleted by their IDs. + +```python +store.delete(["id1", "id2"]) +``` + +### Getting information about the store + +You can get information about your database like the distance metric dimension using the info function. + +When an insert happens, the database an indexing takes place. While this is happening new vectors can not be queried. `pendingVectorCount` represents the number of vector that are currently being indexed. + +```python +info = store.info() +print(info) + +# Output: +# {'vectorCount': 44, 'pendingVectorCount': 0, 'indexSize': 2642412, 'dimension': 1536, 'similarityFunction': 'COSINE'} +``` + +# Upstash Redis This page covers how to use [Upstash Redis](https://upstash.com/redis) with LangChain. @@ -12,7 +136,6 @@ This page covers how to use [Upstash Redis](https://upstash.com/redis) with Lang ## Integrations All of Upstash-LangChain integrations are based on `upstash-redis` Python SDK being utilized as wrappers for LangChain. This SDK utilizes Upstash Redis DB by giving UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN parameters from the console. -One significant advantage of this is that, this SDK uses a REST API. This means, you can run this in serverless platforms, edge or any platform that does not support TCP connections. ### Cache From ea654ad97d45bbe8e8c5b0576c7386ad16e15235 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 17:50:56 +0300 Subject: [PATCH 21/41] Cleanup --- .../docs/integrations/vectorstores/upstash.ipynb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb index 461bc3f67367f..8db8d5578801a 100644 --- a/docs/docs/integrations/vectorstores/upstash.ipynb +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -97,11 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "# from langchain_community.vectorstores.upstash import UpstashVectorStore\n", - "from langchain_openai import OpenAIEmbeddings\n", - "\n", - "# TODO: Delete before push\n", - "from libs.community.langchain_community.vectorstores.upstash import UpstashVectorStore\n", + "from langchain_community.vectorstores.upstash import UpstashVectorStore\n", "from langchain_openai import OpenAIEmbeddings\n", "\n", "import os\n", @@ -110,11 +106,6 @@ "os.environ[\"UPSTASH_VECTOR_URL\"] = \"\"\n", "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"\"\n", "\n", - "# TODO: Delete before push\n", - "os.environ[\"OPENAI_API_KEY\"] = \"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\"\n", - "os.environ[\"UPSTASH_VECTOR_URL\"] = \"https://sincere-serval-66939-us1-vector.upstash.io\"\n", - "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"ABgFMHNpbmNlcmUtc2VydmFsLTY2OTM5LXVzMWFkbWluWVdVMk56bGtOV010WkRVNVl5MDBOR0kwTFdKaE5HVXRNRFkyTldGalpqa3lZV1Zq\"\n", - "\n", "# Create an embeddings instance\n", "embeddings = OpenAIEmbeddings()\n", "\n", @@ -156,10 +147,7 @@ "from langchain_community.document_loaders import TextLoader\n", "from langchain_openai import OpenAIEmbeddings\n", "\n", - "# TODO: Delete before push\n", - "loader = TextLoader(\"docs/docs/modules/state_of_the_union.txt\")\n", - "\n", - "# loader = TextLoader(\"../../modules/state_of_the_union.txt\")\n", + "loader = TextLoader(\"../../modules/state_of_the_union.txt\")\n", "documents = loader.load()\n", "text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)\n", "docs = text_splitter.split_documents(documents)\n", From 81ea626f60eb8a81be8134a879d503c177f80e25 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 19:53:26 +0300 Subject: [PATCH 22/41] Better description --- .../vectorstores/upstash.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 40d74afde1007..93cc2643253f8 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -21,11 +21,13 @@ class UpstashVectorStore(VectorStore): - """Upstash Vector vector store. + """Upstash Vector vector store - To use, you should have the ``upstash_vector`` python package installed. + To use, the ``upstash-vector`` python package must be installed. - Create a new Upstash Vector database and copy the `index_url` and `index_token`. + Also an Upstash Vector index is required. First create a new Upstash Vector index + and copy the `index_url` and `index_token` variables. Then either pass them through the + constructor or set the environment variables `UPSTASH_VECTOR_REST_URL` and `UPSTASH_VECTOR_REST_TOKEN`. Example: .. code-block:: python @@ -39,6 +41,17 @@ class UpstashVectorStore(VectorStore): index_url="...", index_token="..." ) + + # or + + import os + + os.environ["UPSTASH_VECTOR_REST_URL"] = "..." + os.environ["UPSTASH_VECTOR_REST_TOKEN"] = "..." + + vectorstore = UpstashVectorStore( + embedding=embeddings + ) """ def __init__( From 9ab3ce3a344b98190fdc390c0ca0d7c43117e6ce Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 19:54:08 +0300 Subject: [PATCH 23/41] Fix naming --- libs/community/langchain_community/vectorstores/upstash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 93cc2643253f8..a3fd9d4578830 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -68,7 +68,7 @@ def __init__( If index or index_url and index_token are not provided, the constructor will attempt to create an index using the environment variables - `UPSTASH_VECTOR_URL`and `UPSTASH_VECTOR_TOKEN`. + `UPSTASH_VECTOR_REST_URL`and `UPSTASH_VECTOR_REST_TOKEN`. Args: text_key: Key to store the text in metadata. From 2fd9651c0ff958df12f8517d10bd51df2ddfbba8 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:03:27 +0300 Subject: [PATCH 24/41] Add support for with relevance scores functions --- .../vectorstores/upstash.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index a3fd9d4578830..7948b6ee13337 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -2,7 +2,7 @@ import logging import uuid -from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple import numpy as np from langchain_core.documents import Document @@ -377,13 +377,14 @@ async def asimilarity_search_with_score( self._embed_query(query), k=k ) - def _results_to_docs(self, results: List): + def _process_results(self, results: List) -> List[Tuple[Document, float]]: docs = [] for res in results: metadata = res.metadata if metadata and self._text_key in metadata: text = metadata.pop(self._text_key) - docs.append(Document(page_content=text, metadata=metadata)) + doc = Document(page_content=text, metadata=metadata) + docs.append((doc, res.score)) else: logger.warning( f"Found document with no `{self._text_key}` key. Skipping." @@ -403,7 +404,7 @@ def similarity_search_by_vector_with_score( include_metadata=True, ) - return self._results_to_docs(results) + return self._process_results(results) async def asimilarity_search_by_vector_with_score( self, @@ -418,7 +419,7 @@ async def asimilarity_search_by_vector_with_score( include_metadata=True, ) - return self._results_to_docs(results) + return self._process_results(results) def similarity_search( self, @@ -486,6 +487,28 @@ async def asimilarity_search_by_vector( embedding, k=k) return [doc for doc, _ in docs_and_scores] + def _similarity_search_with_relevance_scores( + self, + query: str, + k: int = 4, + **kwargs: Any, + ) -> List[Tuple[Document, float]]: + """ + Since Upstash always returns relevance scores, default implementation is used. + """ + return self.similarity_search_with_score(query, k=k, **kwargs) + + async def _asimilarity_search_with_relevance_scores( + self, + query: str, + k: int = 4, + **kwargs: Any, + ) -> List[Tuple[Document, float]]: + """ + Since Upstash always returns relevance scores, default implementation is used. + """ + return await self.asimilarity_search_with_score(query, k=k, **kwargs) + def max_marginal_relevance_search_by_vector( self, embedding: List[float], From 4dc962a88639afebff736f0b53ee220e16091dbe Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:23:47 +0300 Subject: [PATCH 25/41] Add missing ids --- libs/community/langchain_community/vectorstores/upstash.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 7948b6ee13337..8a3eaa6c42a6e 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -166,6 +166,7 @@ def _embed_query(self, text: str) -> List[float]: def add_documents( self, documents: Iterable[Document], + ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, ) -> List[str]: @@ -194,12 +195,14 @@ def add_documents( texts, metadatas=metadatas, batch_size=batch_size, + ids=ids, embedding_chunk_size=embedding_chunk_size, ) async def aadd_documents( self, documents: Iterable[Document], + ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, ) -> List[str]: @@ -227,6 +230,7 @@ async def aadd_documents( return self.aadd_texts( texts, metadatas=metadatas, + ids=ids, batch_size=batch_size, embedding_chunk_size=embedding_chunk_size, ) From 073f754552925e7f328f6244fd79c3c01845790e Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:23:52 +0300 Subject: [PATCH 26/41] Improve tests --- .../vectorstores/test_upstash.py | 84 +++++++++++-------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index f257493fd4ece..f148312b94843 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -18,12 +18,13 @@ def fixture(): index = Index.from_env() index.reset() - wait_for_indexing() + wait_for_indexing(index) -def wait_for_indexing(): - # Wait for indexing to complete - sleep(1) +def wait_for_indexing(store: UpstashVectorStore): + while store.info().pending_vector_count != 0: + # Wait for indexing to complete + sleep(0.5) def is_api_accessible(url: str) -> bool: @@ -37,10 +38,10 @@ def is_api_accessible(url: str) -> bool: def test_upstash() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) - wait_for_indexing() - output = docsearch.similarity_search("foo", k=1) + wait_for_indexing(store) + output = store.similarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -48,10 +49,10 @@ def test_upstash() -> None: async def test_upstash_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) - wait_for_indexing() - output = await docsearch.asimilarity_search("foo", k=1) + wait_for_indexing(store) + output = await store.asimilarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -59,13 +60,13 @@ def test_upstash_with_metadatas() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] metadatas = [{"page": str(i)} for i in range(len(texts))] - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings(), metadatas=metadatas, ) - wait_for_indexing() - output = docsearch.similarity_search("foo", k=1) + wait_for_indexing(store) + output = store.similarity_search("foo", k=1) assert output == [Document(page_content="foo", metadata={"page": "0"})] @@ -73,13 +74,13 @@ def test_upstash_with_metadatas_with_scores() -> None: """Test end to end construction and scored search.""" texts = ["foo", "bar", "baz"] metadatas = [{"page": str(i)} for i in range(len(texts))] - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings(), metadatas=metadatas, ) - wait_for_indexing() - output = docsearch.similarity_search_with_score("foo", k=1) + wait_for_indexing(store) + output = store.similarity_search_with_score("foo", k=1) assert output == [ (Document(page_content="foo", metadata={"page": "0"}), 1.0)] @@ -90,14 +91,14 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: metadatas = [{"page": str(i)} for i in range(len(texts))] embeddings = FakeEmbeddings() - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=embeddings, metadatas=metadatas, ) - wait_for_indexing() + wait_for_indexing(store) embedded_query = embeddings.embed_query("foo") - output = docsearch.similarity_search_by_vector_with_score( + output = store.similarity_search_by_vector_with_score( embedding=embedded_query, k=1 ) assert output == [ @@ -107,10 +108,10 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=FakeEmbeddings()) - wait_for_indexing() - output = docsearch.max_marginal_relevance_search("foo", k=1) + wait_for_indexing(store) + output = store.max_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -118,11 +119,11 @@ def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] embeddings = FakeEmbeddings() - docsearch = UpstashVectorStore.from_texts( + store = UpstashVectorStore.from_texts( texts=texts, embedding=embeddings) - wait_for_indexing() + wait_for_indexing(store) embedded_query = embeddings.embed_query("foo") - output = docsearch.max_marginal_relevance_search_by_vector( + output = store.max_marginal_relevance_search_by_vector( embedded_query, k=1) assert output == [Document(page_content="foo")] @@ -135,16 +136,26 @@ def test_init_from_index() -> None: assert store.info() is not None -def test_init_from_async_index() -> None: +@pytest.mark.asyncio +async def test_init_from_async_index() -> None: index = AsyncIndex.from_env() store = UpstashVectorStore(async_index=index) - assert store.ainfo() is not None + assert await store.ainfo() is not None + + +def test_init_from_credentials() -> None: + store = UpstashVectorStore( + index_url=os.environ["UPSTASH_VECTOR_REST_URL"], + index_token=os.environ["UPSTASH_VECTOR_REST_TOKEN"], + ) + + assert store.info() is not None @pytest.mark.asyncio -async def test_init_from_credentials() -> None: +async def test_init_from_credentials_async() -> None: store = UpstashVectorStore( index_url=os.environ["UPSTASH_VECTOR_REST_URL"], index_token=os.environ["UPSTASH_VECTOR_REST_TOKEN"], @@ -154,26 +165,25 @@ async def test_init_from_credentials() -> None: def test_upstash_add_documents_no_metadata() -> None: - db = UpstashVectorStore(embedding=FakeEmbeddings()) - db.add_documents([Document(page_content="foo")]) - wait_for_indexing() + store = UpstashVectorStore(embedding=FakeEmbeddings()) + store.add_documents([Document(page_content="foo")]) + wait_for_indexing(store) - search = db.similarity_search("foo") + search = store.similarity_search("foo") assert search == [Document(page_content="foo")] def test_upstash_add_documents_mixed_metadata() -> None: - db = UpstashVectorStore(embedding=FakeEmbeddings()) + store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ Document(page_content="foo"), Document(page_content="bar", metadata={"baz": 1}), ] - print("og docs", docs) ids = ["0", "1"] - actual_ids = db.add_documents(docs, ids=ids) - wait_for_indexing() + actual_ids = store.add_documents(docs, ids=ids) + wait_for_indexing(store) assert actual_ids == ids - search = db.similarity_search("foo bar") + search = store.similarity_search("foo bar") assert sorted(search, key=lambda d: d.page_content) == sorted( docs, key=lambda d: d.page_content ) From 1eb0a95ea1cdbbc9ad9afc84788127278f686726 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:27:12 +0300 Subject: [PATCH 27/41] Add integration tests for async methods --- .../vectorstores/test_upstash.py | 89 ++++++++++++++++--- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index f148312b94843..905cad06055e2 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -27,15 +27,7 @@ def wait_for_indexing(store: UpstashVectorStore): sleep(0.5) -def is_api_accessible(url: str) -> bool: - try: - response = requests.get(url) - return response.status_code == 200 - except Exception: - return False - - -def test_upstash() -> None: +def test_upstash_simple_insert() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] store = UpstashVectorStore.from_texts( @@ -46,7 +38,7 @@ def test_upstash() -> None: @pytest.mark.asyncio -async def test_upstash_async() -> None: +async def test_upstash_simple_insert_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] store = UpstashVectorStore.from_texts( @@ -70,6 +62,21 @@ def test_upstash_with_metadatas() -> None: assert output == [Document(page_content="foo", metadata={"page": "0"})] +@pytest.mark.asyncio +async def test_upstash_with_metadatas_async() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + store = UpstashVectorStore.from_texts( + texts=texts, + embedding=FakeEmbeddings(), + metadatas=metadatas, + ) + wait_for_indexing(store) + output = await store.asimilarity_search("foo", k=1) + assert output == [Document(page_content="foo", metadata={"page": "0"})] + + def test_upstash_with_metadatas_with_scores() -> None: """Test end to end construction and scored search.""" texts = ["foo", "bar", "baz"] @@ -85,6 +92,22 @@ def test_upstash_with_metadatas_with_scores() -> None: (Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.asyncio +async def test_upstash_with_metadatas_with_scores_async() -> None: + """Test end to end construction and scored search.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + store = UpstashVectorStore.from_texts( + texts=texts, + embedding=FakeEmbeddings(), + metadatas=metadatas, + ) + wait_for_indexing(store) + output = await store.asimilarity_search_with_score("foo", k=1) + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + + def test_upstash_with_metadatas_with_scores_using_vector() -> None: """Test end to end construction and scored search, using embedding vector.""" texts = ["foo", "bar", "baz"] @@ -105,6 +128,27 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: (Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.asyncio +async def test_upstash_with_metadatas_with_scores_using_vector_async() -> None: + """Test end to end construction and scored search, using embedding vector.""" + texts = ["foo", "bar", "baz"] + metadatas = [{"page": str(i)} for i in range(len(texts))] + embeddings = FakeEmbeddings() + + store = UpstashVectorStore.from_texts( + texts=texts, + embedding=embeddings, + metadatas=metadatas, + ) + wait_for_indexing(store) + embedded_query = embeddings.embed_query("foo") + output = await store.asimilarity_search_by_vector_with_score( + embedding=embedded_query, k=1 + ) + assert output == [ + (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + + def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -115,6 +159,17 @@ def test_upstash_mmr() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.asyncio +async def test_upstash_mmr_async() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + store = UpstashVectorStore.from_texts( + texts=texts, embedding=FakeEmbeddings()) + wait_for_indexing(store) + output = await store.amax_marginal_relevance_search("foo", k=1) + assert output == [Document(page_content="foo")] + + def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -128,6 +183,20 @@ def test_upstash_mmr_by_vector() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.asyncio +async def test_upstash_mmr_by_vector_async() -> None: + """Test end to end construction and search.""" + texts = ["foo", "bar", "baz"] + embeddings = FakeEmbeddings() + store = UpstashVectorStore.from_texts( + texts=texts, embedding=embeddings) + wait_for_indexing(store) + embedded_query = embeddings.embed_query("foo") + output = await store.amax_marginal_relevance_search_by_vector( + embedded_query, k=1) + assert output == [Document(page_content="foo")] + + def test_init_from_index() -> None: index = Index.from_env() From 19b441e5133523ab495b01e2ea961978ad66eb8a Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:30:49 +0300 Subject: [PATCH 28/41] Improve formatting for the notebook --- docs/docs/integrations/vectorstores/upstash.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb index 8db8d5578801a..93f7955b61e18 100644 --- a/docs/docs/integrations/vectorstores/upstash.ipynb +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -6,11 +6,11 @@ "source": [ "# Upstash Vector\n", "\n", - "[Upstash Vector](https://upstash.com/docs/vector/overall/whatisvector) is a serverless vector database designed for working with vector embeddings.\n", - "\n", - "The vector langchain integration is a wrapper around the [upstash-vector](https://github.com/upstash/vector-py) package.\n", - "\n", - "The python package uses the [vector rest api](https://upstash.com/docs/vector/api/get-started) behind the scenes." + "> [Upstash Vector](https://upstash.com/docs/vector/overall/whatisvector) is a serverless vector database designed for working with vector embeddings.\n", + ">\n", + "> The vector langchain integration is a wrapper around the [upstash-vector](https://github.com/upstash/vector-py) package.\n", + ">\n", + "> The python package uses the [vector rest api](https://upstash.com/docs/vector/api/get-started) behind the scenes." ] }, { From f20aade07c638878eacd249090e1e095bdac6fe3 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:31:41 +0300 Subject: [PATCH 29/41] Remove output in the notebook --- .../integrations/vectorstores/upstash.ipynb | 54 +------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb index 93f7955b61e18..8da19956d9ea4 100644 --- a/docs/docs/integrations/vectorstores/upstash.ipynb +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -34,59 +34,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: langchain-openai in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.0.6)\n", - "Requirement already satisfied: langchain in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.1.3)\n", - "Requirement already satisfied: upstash-vector in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (0.2.0)\n", - "Requirement already satisfied: langchain-core<0.2,>=0.1.16 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (0.1.23)\n", - "Requirement already satisfied: numpy<2,>=1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (1.23.5)\n", - "Requirement already satisfied: openai<2.0.0,>=1.10.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (1.12.0)\n", - "Requirement already satisfied: tiktoken<1,>=0.5.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-openai) (0.5.2)\n", - "Requirement already satisfied: PyYAML>=5.3 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (6.0)\n", - "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.0.25)\n", - "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (3.9.1)\n", - "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.6.3)\n", - "Requirement already satisfied: jsonpatch<2.0,>=1.33 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (1.33)\n", - "Requirement already satisfied: langchain-community<0.1,>=0.0.14 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.0.15)\n", - "Requirement already satisfied: langsmith<0.1,>=0.0.83 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (0.0.87)\n", - "Requirement already satisfied: pydantic<3,>=1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.5.3)\n", - "Requirement already satisfied: requests<3,>=2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (2.31.0)\n", - "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain) (8.2.3)\n", - "Requirement already satisfied: httpx<0.26.0,>=0.25.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from upstash-vector) (0.25.2)\n", - "Requirement already satisfied: attrs>=17.3.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (22.1.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.2)\n", - "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.8.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.3)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.2.0)\n", - "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (3.20.2)\n", - "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (0.9.0)\n", - "Requirement already satisfied: anyio in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (3.5.0)\n", - "Requirement already satisfied: certifi in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (2023.7.22)\n", - "Requirement already satisfied: httpcore==1.* in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (1.0.2)\n", - "Requirement already satisfied: idna in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (3.4)\n", - "Requirement already satisfied: sniffio in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpx<0.26.0,>=0.25.0->upstash-vector) (1.2.0)\n", - "Requirement already satisfied: h11<0.15,>=0.13 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from httpcore==1.*->httpx<0.26.0,>=0.25.0->upstash-vector) (0.14.0)\n", - "Requirement already satisfied: jsonpointer>=1.9 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from jsonpatch<2.0,>=1.33->langchain) (2.4)\n", - "Requirement already satisfied: packaging<24.0,>=23.2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from langchain-core<0.2,>=0.1.16->langchain-openai) (23.2)\n", - "Requirement already satisfied: distro<2,>=1.7.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (1.9.0)\n", - "Requirement already satisfied: tqdm>4 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.66.1)\n", - "Requirement already satisfied: typing-extensions<5,>=4.7 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.7.1)\n", - "Requirement already satisfied: annotated-types>=0.4.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from pydantic<3,>=1->langchain) (0.6.0)\n", - "Requirement already satisfied: pydantic-core==2.14.6 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from pydantic<3,>=1->langchain) (2.14.6)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from requests<3,>=2->langchain) (2.0.4)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from requests<3,>=2->langchain) (1.26.16)\n", - "Requirement already satisfied: regex>=2022.1.18 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from tiktoken<1,>=0.5.2->langchain-openai) (2023.12.25)\n", - "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/kimirti/miniconda3/envs/ai/lib/python3.11/site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain) (1.0.0)\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "%pip install langchain-openai langchain upstash-vector" ] From 7a001462ad732ab2a57d5067534990d31f1481fa Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:37:27 +0300 Subject: [PATCH 30/41] Fix formatting --- libs/community/langchain_community/vectorstores/upstash.py | 5 +++-- .../tests/integration_tests/vectorstores/test_upstash.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 8a3eaa6c42a6e..607766ed073d2 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -26,8 +26,9 @@ class UpstashVectorStore(VectorStore): To use, the ``upstash-vector`` python package must be installed. Also an Upstash Vector index is required. First create a new Upstash Vector index - and copy the `index_url` and `index_token` variables. Then either pass them through the - constructor or set the environment variables `UPSTASH_VECTOR_REST_URL` and `UPSTASH_VECTOR_REST_TOKEN`. + and copy the `index_url` and `index_token` variables. Then either pass + them through the constructor or set the environment + variables `UPSTASH_VECTOR_REST_URL` and `UPSTASH_VECTOR_REST_TOKEN`. Example: .. code-block:: python diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 905cad06055e2..018283fb883af 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -4,10 +4,9 @@ from time import sleep import pytest -import requests from langchain_core.documents import Document +from upstash_vector import AsyncIndex, Index -from upstash_vector import Index, AsyncIndex from langchain_community.vectorstores.upstash import UpstashVectorStore from tests.integration_tests.vectorstores.fake_embeddings import ( FakeEmbeddings, From 8f9a06e6b9e34b87ce3191ed758cdedc519b79c9 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Sun, 18 Feb 2024 20:45:05 +0300 Subject: [PATCH 31/41] Fix formatting --- .../vectorstores/upstash.py | 63 +++++++++---------- .../vectorstores/test_upstash.py | 42 +++++-------- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 607766ed073d2..037946830f869 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -27,7 +27,7 @@ class UpstashVectorStore(VectorStore): Also an Upstash Vector index is required. First create a new Upstash Vector index and copy the `index_url` and `index_token` variables. Then either pass - them through the constructor or set the environment + them through the constructor or set the environment variables `UPSTASH_VECTOR_REST_URL` and `UPSTASH_VECTOR_REST_TOKEN`. Example: @@ -38,8 +38,8 @@ class UpstashVectorStore(VectorStore): embeddings = OpenAIEmbeddings() vectorstore = UpstashVectorStore( - embedding=embeddings, - index_url="...", + embedding=embeddings, + index_url="...", index_token="..." ) @@ -133,8 +133,7 @@ def __init__( if index_url and index_token: self._index = Index(url=index_url, token=index_token) self._async_index = AsyncIndex(url=index_url, token=index_token) - logger.info( - "Created index from the index_url and index_token parameters") + logger.info("Created index from the index_url and index_token parameters") elif not index and not async_index: self._index = Index.from_env() self._async_index = AsyncIndex.from_env() @@ -153,7 +152,8 @@ def _embed_documents(self, texts: Iterable[str]) -> List[List[float]]: if not self._embeddings: raise ValueError( "No embeddings object provided. " - "Pass an embeddings object to the constructor.") + "Pass an embeddings object to the constructor." + ) return self._embeddings.embed_documents(list(texts)) def _embed_query(self, text: str) -> List[float]: @@ -161,7 +161,8 @@ def _embed_query(self, text: str) -> List[float]: if not self._embeddings: raise ValueError( "No embeddings object provided. " - "Pass an embeddings object to the constructor.") + "Pass an embeddings object to the constructor." + ) return self._embeddings.embed_query(text) def add_documents( @@ -174,7 +175,7 @@ def add_documents( """ Get the embeddings for the documents and add them to the vectorstore. - Documents are sent to the embeddings object + Documents are sent to the embeddings object in batches of size `embedding_chunk_size`. The embeddings are then upserted into the vectorstore in batches of size `batch_size`. @@ -210,7 +211,7 @@ async def aadd_documents( """ Get the embeddings for the documents and add them to the vectorstore. - Documents are sent to the embeddings object + Documents are sent to the embeddings object in batches of size `embedding_chunk_size`. The embeddings are then upserted into the vectorstore in batches of size `batch_size`. @@ -247,7 +248,7 @@ def add_texts( """ Get the embeddings for the texts and add them to the vectorstore. - Texts are sent to the embeddings object + Texts are sent to the embeddings object in batches of size `embedding_chunk_size`. The embeddings are then upserted into the vectorstore in batches of size `batch_size`. @@ -278,9 +279,9 @@ def add_texts( metadata[self._text_key] = text for i in range(0, len(texts), embedding_chunk_size): - chunk_texts = texts[i: i + embedding_chunk_size] - chunk_ids = ids[i: i + embedding_chunk_size] - chunk_metadatas = metadatas[i: i + embedding_chunk_size] + chunk_texts = texts[i : i + embedding_chunk_size] + chunk_ids = ids[i : i + embedding_chunk_size] + chunk_metadatas = metadatas[i : i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) for batch in batch_iterate( @@ -301,7 +302,7 @@ async def aadd_texts( """ Get the embeddings for the texts and add them to the vectorstore. - Texts are sent to the embeddings object + Texts are sent to the embeddings object in batches of size `embedding_chunk_size`. The embeddings are then upserted into the vectorstore in batches of size `batch_size`. @@ -332,9 +333,9 @@ async def aadd_texts( metadata[self._text_key] = text for i in range(0, len(texts), embedding_chunk_size): - chunk_texts = texts[i: i + embedding_chunk_size] - chunk_ids = ids[i: i + embedding_chunk_size] - chunk_metadatas = metadatas[i: i + embedding_chunk_size] + chunk_texts = texts[i : i + embedding_chunk_size] + chunk_ids = ids[i : i + embedding_chunk_size] + chunk_metadatas = metadatas[i : i + embedding_chunk_size] embeddings = self._embed_documents(chunk_texts) for batch in batch_iterate( @@ -349,7 +350,7 @@ def similarity_search_with_score( query: str, k: int = 4, ) -> List[Tuple[Document, float]]: - """Retrieve texts most similar to query and + """Retrieve texts most similar to query and convert the result to `Document` objects. Args: @@ -368,7 +369,7 @@ async def asimilarity_search_with_score( query: str, k: int = 4, ) -> List[Tuple[Document, float]]: - """Retrieve texts most similar to query and + """Retrieve texts most similar to query and convert the result to `Document` objects. Args: @@ -440,8 +441,7 @@ def similarity_search( Returns: List of Documents most similar to the query and score for each """ - docs_and_scores = self.similarity_search_with_score( - query, k=k) + docs_and_scores = self.similarity_search_with_score(query, k=k) return [doc for doc, _ in docs_and_scores] async def asimilarity_search( @@ -458,12 +458,12 @@ async def asimilarity_search( Returns: List of Documents most similar to the query """ - docs_and_scores = await self.asimilarity_search_with_score( - query, k=k) + docs_and_scores = await self.asimilarity_search_with_score(query, k=k) return [doc for doc, _ in docs_and_scores] def similarity_search_by_vector( - self, embedding: List[float], k: int = 4) -> List[Document]: + self, embedding: List[float], k: int = 4 + ) -> List[Document]: """Return documents closest to the given embedding. Args: @@ -473,12 +473,12 @@ def similarity_search_by_vector( Returns: List of Documents most similar to the query """ - docs_and_scores = self.similarity_search_by_vector_with_score( - embedding, k=k) + docs_and_scores = self.similarity_search_by_vector_with_score(embedding, k=k) return [doc for doc, _ in docs_and_scores] async def asimilarity_search_by_vector( - self, embedding: List[float], k: int = 4) -> List[Document]: + self, embedding: List[float], k: int = 4 + ) -> List[Document]: """Return documents closest to the given embedding. Args: @@ -489,7 +489,8 @@ async def asimilarity_search_by_vector( List of Documents most similar to the query """ docs_and_scores = await self.asimilarity_search_by_vector_with_score( - embedding, k=k) + embedding, k=k + ) return [doc for doc, _ in docs_and_scores] def _similarity_search_with_relevance_scores( @@ -551,8 +552,7 @@ def max_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop( - (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True for metadata in selected ] @@ -593,8 +593,7 @@ async def amax_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop( - (self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True for metadata in selected ] diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 018283fb883af..a2cf155c774b5 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -13,7 +13,7 @@ ) -@pytest.fixture(scope='function', autouse=True) +@pytest.fixture(scope="function", autouse=True) def fixture(): index = Index.from_env() index.reset() @@ -29,8 +29,7 @@ def wait_for_indexing(store: UpstashVectorStore): def test_upstash_simple_insert() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - store = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings()) + store = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) wait_for_indexing(store) output = store.similarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -40,8 +39,7 @@ def test_upstash_simple_insert() -> None: async def test_upstash_simple_insert_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - store = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings()) + store = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) wait_for_indexing(store) output = await store.asimilarity_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -87,8 +85,7 @@ def test_upstash_with_metadatas_with_scores() -> None: ) wait_for_indexing(store) output = store.similarity_search_with_score("foo", k=1) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] @pytest.mark.asyncio @@ -103,8 +100,7 @@ async def test_upstash_with_metadatas_with_scores_async() -> None: ) wait_for_indexing(store) output = await store.asimilarity_search_with_score("foo", k=1) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] def test_upstash_with_metadatas_with_scores_using_vector() -> None: @@ -120,11 +116,8 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: ) wait_for_indexing(store) embedded_query = embeddings.embed_query("foo") - output = store.similarity_search_by_vector_with_score( - embedding=embedded_query, k=1 - ) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + output = store.similarity_search_by_vector_with_score(embedding=embedded_query, k=1) + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] @pytest.mark.asyncio @@ -144,15 +137,13 @@ async def test_upstash_with_metadatas_with_scores_using_vector_async() -> None: output = await store.asimilarity_search_by_vector_with_score( embedding=embedded_query, k=1 ) - assert output == [ - (Document(page_content="foo", metadata={"page": "0"}), 1.0)] + assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - store = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings()) + store = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) wait_for_indexing(store) output = store.max_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -162,8 +153,7 @@ def test_upstash_mmr() -> None: async def test_upstash_mmr_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] - store = UpstashVectorStore.from_texts( - texts=texts, embedding=FakeEmbeddings()) + store = UpstashVectorStore.from_texts(texts=texts, embedding=FakeEmbeddings()) wait_for_indexing(store) output = await store.amax_marginal_relevance_search("foo", k=1) assert output == [Document(page_content="foo")] @@ -173,12 +163,10 @@ def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] embeddings = FakeEmbeddings() - store = UpstashVectorStore.from_texts( - texts=texts, embedding=embeddings) + store = UpstashVectorStore.from_texts(texts=texts, embedding=embeddings) wait_for_indexing(store) embedded_query = embeddings.embed_query("foo") - output = store.max_marginal_relevance_search_by_vector( - embedded_query, k=1) + output = store.max_marginal_relevance_search_by_vector(embedded_query, k=1) assert output == [Document(page_content="foo")] @@ -187,12 +175,10 @@ async def test_upstash_mmr_by_vector_async() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] embeddings = FakeEmbeddings() - store = UpstashVectorStore.from_texts( - texts=texts, embedding=embeddings) + store = UpstashVectorStore.from_texts(texts=texts, embedding=embeddings) wait_for_indexing(store) embedded_query = embeddings.embed_query("foo") - output = await store.amax_marginal_relevance_search_by_vector( - embedded_query, k=1) + output = await store.amax_marginal_relevance_search_by_vector(embedded_query, k=1) assert output == [Document(page_content="foo")] From f72a3e65ddac3ea2720d46c1ab8d04780ee14fa4 Mon Sep 17 00:00:00 2001 From: ytkimirti Date: Tue, 20 Feb 2024 13:39:16 +0300 Subject: [PATCH 32/41] Fix formatting --- .../integrations/vectorstores/upstash.ipynb | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb index 8da19956d9ea4..b6821c2dd4ea2 100644 --- a/docs/docs/integrations/vectorstores/upstash.ipynb +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -47,11 +47,11 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", + "\n", "from langchain_community.vectorstores.upstash import UpstashVectorStore\n", "from langchain_openai import OpenAIEmbeddings\n", "\n", - "import os\n", - "\n", "os.environ[\"OPENAI_API_KEY\"] = \"\"\n", "os.environ[\"UPSTASH_VECTOR_URL\"] = \"\"\n", "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"\"\n", @@ -60,9 +60,7 @@ "embeddings = OpenAIEmbeddings()\n", "\n", "# Create a vector store instance\n", - "store = UpstashVectorStore(\n", - " embedding=embeddings\n", - ")" + "store = UpstashVectorStore(embedding=embeddings)" ] }, { @@ -165,17 +163,13 @@ } ], "source": [ - "store.add_texts([\"This is a test\", \"This is another test\"],\n", - " [{\n", - " \"title\": \"Test 1\",\n", - " \"author\": \"John Doe\",\n", - " \"date\": \"2021-01-01\"\n", - " },\n", - " {\n", - " \"title\": \"Test 2\",\n", - " \"author\": \"Jane Doe\",\n", - " \"date\": \"2021-01-02\"\n", - " }])" + "store.add_texts(\n", + " [\"This is a test\", \"This is another test\"],\n", + " [\n", + " {\"title\": \"Test 1\", \"author\": \"John Doe\", \"date\": \"2021-01-01\"},\n", + " {\"title\": \"Test 2\", \"author\": \"Jane Doe\", \"date\": \"2021-01-02\"},\n", + " ],\n", + ")" ] }, { @@ -211,10 +205,7 @@ } ], "source": [ - "result = store.similarity_search(\n", - " \"The United States of America\",\n", - " k=5\n", - ")\n", + "result = store.similarity_search(\"The United States of America\", k=5)\n", "result" ] }, @@ -247,10 +238,7 @@ } ], "source": [ - "result = store.similarity_search_with_score(\n", - " \"The United States of America\",\n", - " k=5,\n", - ")\n", + "result = store.similarity_search(\"The United States of America\", k=5)\n", "\n", "for doc, score in result:\n", " print(f\"{doc.metadata} - {score}\")" From 2e64b3eadb209345a7e68bd675c6e31617abec82 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Mon, 22 Apr 2024 15:36:22 +0300 Subject: [PATCH 33/41] add metadata filtering to UpstashVectorStore --- .../vectorstores/upstash.py | 96 ++++++++++++++++--- .../vectorstores/test_upstash.py | 79 +++++++++++++++ 2 files changed, 163 insertions(+), 12 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 037946830f869..9753073c41363 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -349,6 +349,8 @@ def similarity_search_with_score( self, query: str, k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Tuple[Document, float]]: """Retrieve texts most similar to query and convert the result to `Document` objects. @@ -356,18 +358,21 @@ def similarity_search_with_score( Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query and score for each """ return self.similarity_search_by_vector_with_score( - self._embed_query(query), k=k + self._embed_query(query), k=k, filter=filter, **kwargs ) async def asimilarity_search_with_score( self, query: str, k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Tuple[Document, float]]: """Retrieve texts most similar to query and convert the result to `Document` objects. @@ -375,12 +380,13 @@ async def asimilarity_search_with_score( Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query and score for each """ return await self.asimilarity_search_by_vector_with_score( - self._embed_query(query), k=k + self._embed_query(query), k=k, filter=filter, **kwargs ) def _process_results(self, results: List) -> List[Tuple[Document, float]]: @@ -401,6 +407,8 @@ def similarity_search_by_vector_with_score( self, embedding: List[float], k: int = 4, + filter: Optional[str] = None, + **kwargs: Any ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" @@ -408,6 +416,8 @@ def similarity_search_by_vector_with_score( vector=embedding, top_k=k, include_metadata=True, + filter=filter, + **kwargs ) return self._process_results(results) @@ -416,6 +426,8 @@ async def asimilarity_search_by_vector_with_score( self, embedding: List[float], k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" @@ -423,6 +435,8 @@ async def asimilarity_search_by_vector_with_score( vector=embedding, top_k=k, include_metadata=True, + filter=filter, + **kwargs ) return self._process_results(results) @@ -431,65 +445,87 @@ def similarity_search( self, query: str, k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return documents most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query and score for each """ - docs_and_scores = self.similarity_search_with_score(query, k=k) + docs_and_scores = self.similarity_search_with_score( + query, k=k, filter=filter, **kwargs + ) return [doc for doc, _ in docs_and_scores] async def asimilarity_search( self, query: str, k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return documents most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query """ - docs_and_scores = await self.asimilarity_search_with_score(query, k=k) + docs_and_scores = await self.asimilarity_search_with_score( + query, k=k, filter=filter, **kwargs + ) return [doc for doc, _ in docs_and_scores] def similarity_search_by_vector( - self, embedding: List[float], k: int = 4 + self, + embedding: List[float], + k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return documents closest to the given embedding. Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query """ - docs_and_scores = self.similarity_search_by_vector_with_score(embedding, k=k) + docs_and_scores = self.similarity_search_by_vector_with_score( + embedding, k=k, filter=filter, **kwargs + ) return [doc for doc, _ in docs_and_scores] async def asimilarity_search_by_vector( - self, embedding: List[float], k: int = 4 + self, + embedding: List[float], + k: int = 4, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return documents closest to the given embedding. Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. + filter: Optional metadata filter in str format Returns: List of Documents most similar to the query """ docs_and_scores = await self.asimilarity_search_by_vector_with_score( - embedding, k=k + embedding, k=k, filter=filter, **kwargs ) return [doc for doc, _ in docs_and_scores] @@ -497,23 +533,29 @@ def _similarity_search_with_relevance_scores( self, query: str, k: int = 4, + filter: Optional[str] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """ Since Upstash always returns relevance scores, default implementation is used. """ - return self.similarity_search_with_score(query, k=k, **kwargs) + return self.similarity_search_with_score( + query, k=k, filter=filter, **kwargs + ) async def _asimilarity_search_with_relevance_scores( self, query: str, k: int = 4, + filter: Optional[str] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """ Since Upstash always returns relevance scores, default implementation is used. """ - return await self.asimilarity_search_with_score(query, k=k, **kwargs) + return await self.asimilarity_search_with_score( + query, k=k, filter=filter, **kwargs + ) def max_marginal_relevance_search_by_vector( self, @@ -521,6 +563,8 @@ def max_marginal_relevance_search_by_vector( k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. @@ -535,6 +579,8 @@ def max_marginal_relevance_search_by_vector( of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. + filter: Optional metadata filter in str format + Returns: List of Documents selected by maximal marginal relevance. """ @@ -543,6 +589,8 @@ def max_marginal_relevance_search_by_vector( top_k=fetch_k, include_vectors=True, include_metadata=True, + filter=filter, + **kwargs ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), @@ -562,6 +610,8 @@ async def amax_marginal_relevance_search_by_vector( k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. @@ -576,6 +626,8 @@ async def amax_marginal_relevance_search_by_vector( of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. + filter: Optional metadata filter in str format + Returns: List of Documents selected by maximal marginal relevance. """ @@ -584,6 +636,8 @@ async def amax_marginal_relevance_search_by_vector( top_k=fetch_k, include_vectors=True, include_metadata=True, + filter=filter, + **kwargs ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), @@ -603,6 +657,8 @@ def max_marginal_relevance_search( k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. @@ -617,12 +673,19 @@ def max_marginal_relevance_search( of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. + filter: Optional metadata filter in str format + Returns: List of Documents selected by maximal marginal relevance. """ embedding = self._embed_query(query) return self.max_marginal_relevance_search_by_vector( - embedding=embedding, k=k, fetch_k=fetch_k, lambda_mult=lambda_mult + embedding=embedding, + k=k, + fetch_k=fetch_k, + lambda_mult=lambda_mult, + filter=filter, + **kwargs ) async def amax_marginal_relevance_search( @@ -631,6 +694,8 @@ async def amax_marginal_relevance_search( k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, + filter: Optional[str] = None, + **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. @@ -645,12 +710,19 @@ async def amax_marginal_relevance_search( of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. + filter: Optional metadata filter in str format + Returns: List of Documents selected by maximal marginal relevance. """ embedding = self._embed_query(query) return await self.amax_marginal_relevance_search_by_vector( - embedding=embedding, k=k, fetch_k=fetch_k, lambda_mult=lambda_mult + embedding=embedding, + k=k, + fetch_k=fetch_k, + lambda_mult=lambda_mult, + filter=filter, + **kwargs ) @classmethod diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index a2cf155c774b5..3e8dc69472ee2 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -241,3 +241,82 @@ def test_upstash_add_documents_mixed_metadata() -> None: assert sorted(search, key=lambda d: d.page_content) == sorted( docs, key=lambda d: d.page_content ) + +def test_upstash_similarity_search_with_metadata() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = store.similarity_search( + query="foo", + k=5, + filter="waldo = 1" + ) + + assert result == [ + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + ] + + result = store.similarity_search_with_score( + query="foo", + k=5, + filter="waldo = 2" + ) + + assert len(result) == 1 + assert result[0][0] == Document(page_content="fred", metadata={"waldo": 2}) + assert round(result[0][1], 2) == 0.85 + +def test_upstash_similarity_search_by_vector_with_metadata() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = store.similarity_search_by_vector_with_score( + embedding=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + k=5, + filter="waldo = 1" + ) + + assert len(result) == 2 + assert result[0] == (Document(page_content='bar', metadata={'waldo': 1}), 1.0) + assert result[1][0] == Document(page_content='baz', metadata={'waldo': 1}) + assert round(result[1][1], 2) == 0.98 + +def test_upstash_max_marginal_relevance_search_with_metadata() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = store.max_marginal_relevance_search( + query="foo", + k=3, + filter="waldo = 1" + ) + + assert result == [ + Document(page_content='bar', metadata={'waldo': 1}), + Document(page_content='baz', metadata={'waldo': 1}) + ] From bed42447187dc626be3596e0c5221868d85506ce Mon Sep 17 00:00:00 2001 From: CahidArda Date: Mon, 22 Apr 2024 19:44:31 +0300 Subject: [PATCH 34/41] add native embedding to UpstashVectorStore --- .../vectorstores/upstash.py | 103 +++++-- .../tests/integration_tests/.env.example | 4 + .../vectorstores/test_upstash.py | 266 +++++++++++++++++- 3 files changed, 350 insertions(+), 23 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 9753073c41363..4c32cafd6f619 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -2,7 +2,7 @@ import logging import uuid -from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple +from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple, Union import numpy as np from langchain_core.documents import Document @@ -62,7 +62,7 @@ def __init__( async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, index_token: Optional[str] = None, - embedding: Optional[Embeddings] = None, + embedding: Optional[Union[Embeddings, bool]] = None, ): """ Constructor for UpstashVectorStore. @@ -78,7 +78,10 @@ def __init__( functions are needed index_url: URL of the UpstashVector index. index_token: Token of the UpstashVector index. - embedding: Embeddings object. + embedding: Embeddings object or a boolean. When false, no embedding + is applied. If true, Upstash embeddings are used. When Upstash + embeddings are used, text is sent directly to Upstash and + embedding is applied there instead of embedding in Langchain. Example: .. code-block:: python @@ -143,27 +146,37 @@ def __init__( self._text_key = text_key @property - def embeddings(self) -> Optional[Embeddings]: + def embeddings(self) -> Optional[Union[Embeddings, bool]]: """Access the query embedding object if available.""" return self._embeddings - def _embed_documents(self, texts: Iterable[str]) -> List[List[float]]: + def _embed_documents(self, texts: Iterable[str]) -> Union[List[List[float], List[str]]]: """Embed strings using the embeddings object""" if not self._embeddings: raise ValueError( "No embeddings object provided. " "Pass an embeddings object to the constructor." ) - return self._embeddings.embed_documents(list(texts)) - - def _embed_query(self, text: str) -> List[float]: + if isinstance(self._embeddings, Embeddings): + return self._embeddings.embed_documents(list(texts)) + + # using self._embeddings is True, Upstash embeddings will be used. + # returning list of text as List[str] + return list(texts) + + def _embed_query(self, text: str) -> Union[List[float], str]: """Embed query text using the embeddings object.""" if not self._embeddings: raise ValueError( "No embeddings object provided. " "Pass an embeddings object to the constructor." ) - return self._embeddings.embed_query(text) + if isinstance(self._embeddings, Embeddings): + return self._embeddings.embed_query(text) + + # using self._embeddings is True, Upstash embeddings will be used. + # returning query as it is + return text def add_documents( self, @@ -229,7 +242,7 @@ async def aadd_documents( texts = [doc.page_content for doc in documents] metadatas = [doc.metadata for doc in documents] - return self.aadd_texts( + return await self.aadd_texts( texts, metadatas=metadatas, ids=ids, @@ -405,15 +418,20 @@ def _process_results(self, results: List) -> List[Tuple[Document, float]]: def similarity_search_by_vector_with_score( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, filter: Optional[str] = None, **kwargs: Any ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" + payload = ( + {"data": embedding} + if isinstance(embedding, str) + else {"vector": embedding} + ) results = self._index.query( - vector=embedding, + **payload, top_k=k, include_metadata=True, filter=filter, @@ -424,15 +442,20 @@ def similarity_search_by_vector_with_score( async def asimilarity_search_by_vector_with_score( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, filter: Optional[str] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" + payload = ( + {"data": embedding} + if isinstance(embedding, str) + else {"vector": embedding} + ) results = await self._async_index.query( - vector=embedding, + **payload, top_k=k, include_metadata=True, filter=filter, @@ -487,7 +510,7 @@ async def asimilarity_search( def similarity_search_by_vector( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, filter: Optional[str] = None, **kwargs: Any, @@ -509,7 +532,7 @@ def similarity_search_by_vector( async def asimilarity_search_by_vector( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, filter: Optional[str] = None, **kwargs: Any, @@ -584,6 +607,7 @@ def max_marginal_relevance_search_by_vector( Returns: List of Documents selected by maximal marginal relevance. """ + assert isinstance(self.embeddings, Embeddings) results = self._index.query( vector=embedding, top_k=fetch_k, @@ -631,6 +655,7 @@ async def amax_marginal_relevance_search_by_vector( Returns: List of Documents selected by maximal marginal relevance. """ + assert isinstance(self.embeddings, Embeddings) results = await self._async_index.query( vector=embedding, top_k=fetch_k, @@ -771,6 +796,52 @@ def from_texts( ) return vector_store + @classmethod + async def afrom_texts( + cls, + texts: List[str], + embedding: Embeddings, + metadatas: Optional[List[dict]] = None, + ids: Optional[List[str]] = None, + embedding_chunk_size: int = 1000, + batch_size: int = 32, + text_key: str = "text", + index: Optional[Index] = None, + async_index: Optional[AsyncIndex] = None, + index_url: Optional[str] = None, + index_token: Optional[str] = None, + ) -> UpstashVectorStore: + """Create a new UpstashVectorStore from a list of texts. + + Example: + .. code-block:: python + from langchain_community.vectorstores.upstash import UpstashVectorStore + from langchain_community.embeddings import OpenAIEmbeddings + + embeddings = OpenAIEmbeddings() + vector_store = UpstashVectorStore.from_texts( + texts, + embeddings, + ) + """ + vector_store = cls( + embedding=embedding, + text_key=text_key, + index=index, + async_index=async_index, + index_url=index_url, + index_token=index_token, + ) + + await vector_store.aadd_texts( + texts, + metadatas=metadatas, + ids=ids, + batch_size=batch_size, + embedding_chunk_size=embedding_chunk_size, + ) + return vector_store + def delete( self, ids: Optional[List[str]] = None, diff --git a/libs/community/tests/integration_tests/.env.example b/libs/community/tests/integration_tests/.env.example index d1c77e281e760..44a4490e1e65f 100644 --- a/libs/community/tests/integration_tests/.env.example +++ b/libs/community/tests/integration_tests/.env.example @@ -59,5 +59,9 @@ KINETICA_PASSWD = _password_here # Upstash Vector +# Create two Upstash Vector instances. First one should have dimensionality of 10. +# Second one should be created with embedding model BAA/bge-small-en-V1.5 UPSTASH_VECTOR_URL=your_upstash_vector_url UPSTASH_VECTOR_TOKEN=your_upstash_vector_token +UPSTASH_VECTOR_URL_EMBEDDING=your_upstash_vector_embedding_url +UPSTASH_VECTOR_TOKEN_EMBEDDING=your_upstash_vector_embedding_token diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 3e8dc69472ee2..cb06bdbc33ffe 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -2,6 +2,7 @@ import os from time import sleep +from typing import List, Union, Dict import pytest from langchain_core.documents import Document @@ -16,8 +17,16 @@ @pytest.fixture(scope="function", autouse=True) def fixture(): index = Index.from_env() + embedding_index = Index( + url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + ) + index.reset() + embedding_index.reset() + wait_for_indexing(index) + wait_for_indexing(embedding_index) def wait_for_indexing(store: UpstashVectorStore): @@ -26,6 +35,23 @@ def wait_for_indexing(store: UpstashVectorStore): sleep(0.5) +def check_response_with_score( + result: List[Dict[str, Union[Document, float]]], + expected: List[Dict[str, Union[Document, float]]] + ): + """ + check the result of a search with scores with an expected value + + scores in result will be rounded by two digits + """ + result = list(map( + lambda result: (result[0], round(result[1], 2)), + result + )) + + assert result == expected + + def test_upstash_simple_insert() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -271,9 +297,49 @@ def test_upstash_similarity_search_with_metadata() -> None: filter="waldo = 2" ) - assert len(result) == 1 - assert result[0][0] == Document(page_content="fred", metadata={"waldo": 2}) - assert round(result[0][1], 2) == 0.85 + check_response_with_score( + result, + [ + (Document(page_content='fred', metadata={'waldo': 2}), 0.85) + ] + ) + +@pytest.mark.asyncio +async def test_upstash_similarity_search_with_metadata_async() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = await store.asimilarity_search( + query="foo", + k=5, + filter="waldo = 1" + ) + + assert result == [ + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + ] + + result = await store.asimilarity_search_with_score( + query="foo", + k=5, + filter="waldo = 2" + ) + + check_response_with_score( + result, + [ + (Document(page_content='fred', metadata={'waldo': 2}), 0.85) + ] + ) def test_upstash_similarity_search_by_vector_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -293,10 +359,40 @@ def test_upstash_similarity_search_by_vector_with_metadata() -> None: filter="waldo = 1" ) - assert len(result) == 2 - assert result[0] == (Document(page_content='bar', metadata={'waldo': 1}), 1.0) - assert result[1][0] == Document(page_content='baz', metadata={'waldo': 1}) - assert round(result[1][1], 2) == 0.98 + check_response_with_score( + result, + [ + (Document(page_content='bar', metadata={'waldo': 1}), 1.0), + (Document(page_content='baz', metadata={'waldo': 1}), 0.98) + ] + ) + +@pytest.mark.asyncio +async def test_upstash_similarity_search_by_vector_with_metadata_async() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = await store.asimilarity_search_by_vector_with_score( + embedding=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], + k=5, + filter="waldo = 1" + ) + + check_response_with_score( + result, + [ + (Document(page_content='bar', metadata={'waldo': 1}), 1.0), + (Document(page_content='baz', metadata={'waldo': 1}), 0.98) + ] + ) def test_upstash_max_marginal_relevance_search_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -320,3 +416,159 @@ def test_upstash_max_marginal_relevance_search_with_metadata() -> None: Document(page_content='bar', metadata={'waldo': 1}), Document(page_content='baz', metadata={'waldo': 1}) ] + +@pytest.mark.asyncio +async def test_upstash_max_marginal_relevance_search_with_metadata_async() -> None: + store = UpstashVectorStore(embedding=FakeEmbeddings()) + docs = [ + Document(page_content="foo"), + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), + Document(page_content="fred", metadata={"waldo": 2}), + ] + ids = ["0", "1", "3", "4"] + store.add_documents(docs, ids=ids) + wait_for_indexing(store) + + result = await store.amax_marginal_relevance_search( + query="foo", + k=3, + filter="waldo = 1" + ) + + assert result == [ + Document(page_content='bar', metadata={'waldo': 1}), + Document(page_content='baz', metadata={'waldo': 1}) + ] + + +def test_embeddings_configurations(): + """ + test the behavior of the vector store for different `embeddings` parameter + values + """ + # case 1: use FakeEmbeddings, a subclass of Embeddings + store = UpstashVectorStore(embedding=FakeEmbeddings()) + embedding = store._embed_query("query") + assert embedding == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] + + embedding = store._embed_documents(["doc1", "doc2"]) + assert embedding == [ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + ] + + # case 2: pass False as embedding + store = UpstashVectorStore(embedding=False) + with pytest.raises(ValueError): + embedding = store._embed_query("query") + + with pytest.raises(ValueError): + embedding = store._embed_documents(["doc1", "doc2"]) + + # case 3: pass True as embedding + # Upstash embeddings will be used + store = UpstashVectorStore( + index=Index( + url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + ), + embedding=True, + ) + embedding = store._embed_query("query") + assert embedding == "query" + embedding = store._embed_documents(["doc1", "doc2"]) + assert embedding == ["doc1", "doc2"] + +def test_embedding_index(): + + store = UpstashVectorStore( + index=Index( + url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + ), + embedding=True, + ) + + # add documents + result = store.add_documents( + [ + Document(page_content="penguin", metadata={"topic": "bird"}), + Document(page_content="albatros", metadata={"topic": "bird"}), + Document(page_content="beethoven", metadata={"topic": "composer"}), + Document(page_content="rachmaninoff", metadata={"topic": "composer"}), + ] + ) + wait_for_indexing(store) + + # similarity search + result = store.similarity_search_with_score( + query="eagle", + k=2 + ) + check_response_with_score( + result, + [ + (Document(page_content='penguin', metadata={'topic': 'bird'}), 0.82), + (Document(page_content='albatros', metadata={'topic': 'bird'}), 0.78) + ] + ) + + # similarity search with relevance score + result = store.similarity_search_with_relevance_scores( + query="mozart", + k=2 + ) + check_response_with_score( + result, + [ + (Document(page_content='beethoven', metadata={'topic': 'composer'}), 0.88), + (Document(page_content='rachmaninoff', metadata={'topic': 'composer'}), 0.84) + ] + ) + +@pytest.mark.asyncio +async def test_embedding_index_async(): + + store = UpstashVectorStore( + index_url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], + embedding=True, + ) + + # add documents + result = await store.aadd_documents( + [ + Document(page_content="penguin", metadata={"topic": "bird"}), + Document(page_content="albatros", metadata={"topic": "bird"}), + Document(page_content="beethoven", metadata={"topic": "composer"}), + Document(page_content="rachmaninoff", metadata={"topic": "composer"}), + ] + ) + wait_for_indexing(store) + + # similarity search + result = await store.asimilarity_search_with_score( + query="eagle", + k=2 + ) + check_response_with_score( + result, + [ + (Document(page_content='penguin', metadata={'topic': 'bird'}), 0.82), + (Document(page_content='albatros', metadata={'topic': 'bird'}), 0.78) + ] + ) + + # similarity search with relevance score + result = await store.asimilarity_search_with_relevance_scores( + query="mozart", + k=2 + ) + check_response_with_score( + result, + [ + (Document(page_content='beethoven', metadata={'topic': 'composer'}), 0.88), + (Document(page_content='rachmaninoff', metadata={'topic': 'composer'}), 0.84) + ] + ) From 6f9e3b0671e3fd4baf07031f395a7e14790d5e18 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Wed, 24 Apr 2024 12:37:05 +0300 Subject: [PATCH 35/41] update Upstash docs with filtering and embedding --- docs/docs/integrations/providers/upstash.mdx | 38 ++++- .../integrations/vectorstores/upstash.ipynb | 146 ++++++++++++------ 2 files changed, 133 insertions(+), 51 deletions(-) diff --git a/docs/docs/integrations/providers/upstash.mdx b/docs/docs/integrations/providers/upstash.mdx index 3efb70df12cff..0b619dcde9526 100644 --- a/docs/docs/integrations/providers/upstash.mdx +++ b/docs/docs/integrations/providers/upstash.mdx @@ -31,13 +31,36 @@ from langchain_community.vectorstores.upstash import UpstashVectorStore import os os.environ["UPSTASH_VECTOR_REST_URL"] = "" -os.environ["UPSTASH_VECTOR_TOKEN"] = "" +os.environ["UPSTASH_VECTOR_REST_TOKEN"] = "" store = UpstashVectorStore( embedding=embeddings ) ``` +An alternative way of `UpstashVectorStore` is to pass `embedding=True`. This is a unique +feature of the `UpstashVectorStore` thanks to the ability of the Upstash Vector indexes +to have an associated embedding model. In this configuration, documents we want to insert or +queries we want to search for are simply sent to Upstash Vector as text. In the background, +Upstash Vector embeds these text and executes the request with these embeddings. To use this +feature, [create an Upstash Vector index by selecting a model](https://upstash.com/docs/vector/features/embeddingmodels#using-a-model) +and simply pass `embedding=True`: + +```python +from langchain_community.vectorstores.upstash import UpstashVectorStore +import os + +os.environ["UPSTASH_VECTOR_REST_URL"] = "" +os.environ["UPSTASH_VECTOR_REST_TOKEN"] = "" + +store = UpstashVectorStore( + embedding=True +) +``` + +See [Upstash Vector documentation](https://upstash.com/docs/vector/features/embeddingmodels) +for more detail on embedding models. + ### Inserting Vectors ```python @@ -102,6 +125,19 @@ result = store.similarity_search_by_vector( ) ``` +When searching, you can also utilize the `filter` parameter which will allow you to filter by metadata: + +```python +result = store.similarity_search( + "The United States of America", + k=5, + filter="type = 'country'" +) +``` + +See [Upstash Vector documentation](https://upstash.com/docs/vector/features/filtering) +for more details on metadata filtering. + ### Deleting Vectors Vectors can be deleted by their IDs. diff --git a/docs/docs/integrations/vectorstores/upstash.ipynb b/docs/docs/integrations/vectorstores/upstash.ipynb index b6821c2dd4ea2..95da0ab26ff2a 100644 --- a/docs/docs/integrations/vectorstores/upstash.ipynb +++ b/docs/docs/integrations/vectorstores/upstash.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -53,8 +53,8 @@ "from langchain_openai import OpenAIEmbeddings\n", "\n", "os.environ[\"OPENAI_API_KEY\"] = \"\"\n", - "os.environ[\"UPSTASH_VECTOR_URL\"] = \"\"\n", - "os.environ[\"UPSTASH_VECTOR_TOKEN\"] = \"\"\n", + "os.environ[\"UPSTASH_VECTOR_REST_URL\"] = \"\"\n", + "os.environ[\"UPSTASH_VECTOR_REST_TOKEN\"] = \"\"\n", "\n", "# Create an embeddings instance\n", "embeddings = OpenAIEmbeddings()\n", @@ -63,6 +63,19 @@ "store = UpstashVectorStore(embedding=embeddings)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "An alternative way of creating `UpstashVectorStore` is to [create an Upstash Vector index by selecting a model](https://upstash.com/docs/vector/features/embeddingmodels#using-a-model) and passing `embedding=True`. In this configuration, documents or queries will be sent to Upstash as text and embedded there.\n", + "\n", + "```python\n", + "store = UpstashVectorStore(embedding=True)\n", + "```\n", + "\n", + "If you are interested in trying out this approach, you can update the initialization of `store` like above and run the rest of the tutorial." + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -74,18 +87,18 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='Putin’s latest attack on Ukraine was premeditated and unprovoked. \\n\\nHe rejected repeated efforts at diplomacy. \\n\\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \\n\\nWe prepared extensively and carefully. \\n\\nWe spent months building a coalition of other freedom-loving nations from Europe and the Americas to Asia and Africa to confront Putin. \\n\\nI spent countless hours unifying our European allies. We shared with the world in advance what we knew Putin was planning and precisely how he would try to falsely justify his aggression. \\n\\nWe countered Russia’s lies with truth. \\n\\nAnd now that he has acted the free world is holding him accountable. \\n\\nAlong with twenty-seven members of the European Union including France, Germany, Italy, as well as countries like the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzerland.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'})]" + "[Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='Putin’s latest attack on Ukraine was premeditated and unprovoked. \\n\\nHe rejected repeated efforts at diplomacy. \\n\\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \\n\\nWe prepared extensively and carefully. \\n\\nWe spent months building a coalition of other freedom-loving nations from Europe and the Americas to Asia and Africa to confront Putin. \\n\\nI spent countless hours unifying our European allies. We shared with the world in advance what we knew Putin was planning and precisely how he would try to falsely justify his aggression. \\n\\nWe countered Russia’s lies with truth. \\n\\nAnd now that he has acted the free world is holding him accountable. \\n\\nAlong with twenty-seven members of the European Union including France, Germany, Italy, as well as countries like the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzerland.', metadata={'source': '../../modules/state_of_the_union.txt'})]" ] }, - "execution_count": 15, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -93,7 +106,6 @@ "source": [ "from langchain.text_splitter import CharacterTextSplitter\n", "from langchain_community.document_loaders import TextLoader\n", - "from langchain_openai import OpenAIEmbeddings\n", "\n", "loader = TextLoader(\"../../modules/state_of_the_union.txt\")\n", "documents = loader.load()\n", @@ -114,20 +126,20 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['95362512-0801-4b33-8e32-91ed563b25e5',\n", - " '7ee0cb06-0987-4d31-9089-c5b6c42fea08',\n", - " '40abd35c-e687-476c-a426-fcbb1fd679d8',\n", - " '4450d872-56b0-49a2-aa91-a5a718815bec',\n", - " '00a6df29-621b-4a48-a7d7-9a81ca4030de']" + "['82b3781b-817c-4a4d-8f8b-cbd07c1d005a',\n", + " 'a20e0a49-29d8-465e-8eae-0bc5ac3d24dc',\n", + " 'c19f4108-b652-4890-873e-d4cad00f1b1a',\n", + " '23d1fcf9-6ee1-4638-8c70-0f5030762301',\n", + " '2d775784-825d-4627-97a3-fee4539d8f58']" ] }, - "execution_count": 25, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -147,27 +159,45 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['6010f8ef-ee75-4c37-8db8-052431a8bd01',\n", - " 'a388f11a-7cc3-4878-a8ac-77ba7c47fb82']" + "['fe1f7a7b-42e2-4828-88b0-5b449c49fe86',\n", + " '154a0021-a99c-427e-befb-f0b2b18ed83c',\n", + " 'a8218226-18a9-4ab5-ade5-5a71b19a7831',\n", + " '62b7ef97-83bf-4b6d-8c93-f471796244dc',\n", + " 'ab43fd2e-13df-46d4-8cf7-e6e16506e4bb',\n", + " '6841e7f9-adaa-41d9-af3d-0813ee52443f',\n", + " '45dda5a1-f0c1-4ac7-9acb-50253e4ee493']" ] }, - "execution_count": 26, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "store.add_texts(\n", - " [\"This is a test\", \"This is another test\"],\n", " [\n", - " {\"title\": \"Test 1\", \"author\": \"John Doe\", \"date\": \"2021-01-01\"},\n", - " {\"title\": \"Test 2\", \"author\": \"Jane Doe\", \"date\": \"2021-01-02\"},\n", + " \"A timeless tale set in the Jazz Age, this novel delves into the lives of affluent socialites, their pursuits of wealth, love, and the elusive American Dream. Amidst extravagant parties and glittering opulence, the story unravels the complexities of desire, ambition, and the consequences of obsession.\",\n", + " \"Set in a small Southern town during the 1930s, this novel explores themes of racial injustice, moral growth, and empathy through the eyes of a young girl. It follows her father, a principled lawyer, as he defends a black man accused of assaulting a white woman, confronting deep-seated prejudices and challenging societal norms along the way.\",\n", + " \"A chilling portrayal of a totalitarian regime, this dystopian novel offers a bleak vision of a future world dominated by surveillance, propaganda, and thought control. Through the eyes of a disillusioned protagonist, it explores the dangers of totalitarianism and the erosion of individual freedom in a society ruled by fear and oppression.\",\n", + " \"Set in the English countryside during the early 19th century, this novel follows the lives of the Bennet sisters as they navigate the intricate social hierarchy of their time. Focusing on themes of marriage, class, and societal expectations, the story offers a witty and insightful commentary on the complexities of romantic relationships and the pursuit of happiness.\",\n", + " \"Narrated by a disillusioned teenager, this novel follows his journey of self-discovery and rebellion against the phoniness of the adult world. Through a series of encounters and reflections, it explores themes of alienation, identity, and the search for authenticity in a society marked by conformity and hypocrisy.\",\n", + " \"In a society where emotion is suppressed and individuality is forbidden, one man dares to defy the oppressive regime. Through acts of rebellion and forbidden love, he discovers the power of human connection and the importance of free will.\",\n", + " \"Set in a future world devastated by environmental collapse, this novel follows a group of survivors as they struggle to survive in a harsh, unforgiving landscape. Amidst scarcity and desperation, they must confront moral dilemmas and question the nature of humanity itself.\",\n", + " ],\n", + " [\n", + " {\"title\": \"The Great Gatsby\", \"author\": \"F. Scott Fitzgerald\", \"year\": 1925},\n", + " {\"title\": \"To Kill a Mockingbird\", \"author\": \"Harper Lee\", \"year\": 1960},\n", + " {\"title\": \"1984\", \"author\": \"George Orwell\", \"year\": 1949},\n", + " {\"title\": \"Pride and Prejudice\", \"author\": \"Jane Austen\", \"year\": 1813},\n", + " {\"title\": \"The Catcher in the Rye\", \"author\": \"J.D. Salinger\", \"year\": 1951},\n", + " {\"title\": \"Brave New World\", \"author\": \"Aldous Huxley\", \"year\": 1932},\n", + " {\"title\": \"The Road\", \"author\": \"Cormac McCarthy\", \"year\": 2006},\n", " ],\n", ")" ] @@ -186,20 +216,20 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[Document(page_content='And my report is this: the State of the Union is strong—because you, the American people, are strong. \\n\\nWe are stronger today than we were a year ago. \\n\\nAnd we will be stronger a year from now than we are today. \\n\\nNow is our moment to meet and overcome the challenges of our time. \\n\\nAnd we will, as one people. \\n\\nOne America. \\n\\nThe United States of America. \\n\\nMay God bless you all. May God protect our troops.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='And built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation. \\n\\nWe will meet the test. \\n\\nTo protect freedom and liberty, to expand fairness and opportunity. \\n\\nWe will save democracy. \\n\\nAs hard as these times have been, I am more optimistic about America today than I have been my whole life. \\n\\nBecause I see the future that is within our grasp. \\n\\nBecause I know there is simply nothing beyond our capacity. \\n\\nWe are the only nation on Earth that has always turned every crisis we have faced into an opportunity. \\n\\nThe only nation that can be defined by a single word: possibilities. \\n\\nSo on this night, in our 245th year as a nation, I have come to report on the State of the Union.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'}),\n", - " Document(page_content='For that purpose we’ve mobilized American ground forces, air squadrons, and ship deployments to protect NATO countries including Poland, Romania, Latvia, Lithuania, and Estonia. \\n\\nAs I have made crystal clear the United States and our Allies will defend every inch of territory of NATO countries with the full force of our collective power. \\n\\nAnd we remain clear-eyed. The Ukrainians are fighting back with pure courage. But the next few days weeks, months, will be hard on them. \\n\\nPutin has unleashed violence and chaos. But while he may make gains on the battlefield – he will pay a continuing high price over the long run. \\n\\nAnd a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards. \\n\\nTo all Americans, I will be honest with you, as I’ve always promised. A Russian dictator, invading a foreign country, has costs around the world.', metadata={'source': 'docs/docs/modules/state_of_the_union.txt'})]" + "[Document(page_content='And my report is this: the State of the Union is strong—because you, the American people, are strong. \\n\\nWe are stronger today than we were a year ago. \\n\\nAnd we will be stronger a year from now than we are today. \\n\\nNow is our moment to meet and overcome the challenges of our time. \\n\\nAnd we will, as one people. \\n\\nOne America. \\n\\nThe United States of America. \\n\\nMay God bless you all. May God protect our troops.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='And built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself. \\n\\nIt is in this moment that our character is formed. Our purpose is found. Our future is forged. \\n\\nWell I know this nation. \\n\\nWe will meet the test. \\n\\nTo protect freedom and liberty, to expand fairness and opportunity. \\n\\nWe will save democracy. \\n\\nAs hard as these times have been, I am more optimistic about America today than I have been my whole life. \\n\\nBecause I see the future that is within our grasp. \\n\\nBecause I know there is simply nothing beyond our capacity. \\n\\nWe are the only nation on Earth that has always turned every crisis we have faced into an opportunity. \\n\\nThe only nation that can be defined by a single word: possibilities. \\n\\nSo on this night, in our 245th year as a nation, I have come to report on the State of the Union.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \\n\\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight. \\n\\nLet each of us here tonight in this Chamber send an unmistakable signal to Ukraine and to the world. \\n\\nPlease rise if you are able and show that, Yes, we the United States of America stand with the Ukrainian people. \\n\\nThroughout our history we’ve learned this lesson when dictators do not pay a price for their aggression they cause more chaos. \\n\\nThey keep moving. \\n\\nAnd the costs and the threats to America and the world keep rising. \\n\\nThat’s why the NATO Alliance was created to secure peace and stability in Europe after World War 2. \\n\\nThe United States is a member along with 29 other nations. \\n\\nIt matters. American diplomacy matters. American resolve matters.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='When we use taxpayer dollars to rebuild America – we are going to Buy American: buy American products to support American jobs. \\n\\nThe federal government spends about $600 Billion a year to keep the country safe and secure. \\n\\nThere’s been a law on the books for almost a century \\nto make sure taxpayers’ dollars support American jobs and businesses. \\n\\nEvery Administration says they’ll do it, but we are actually doing it. \\n\\nWe will buy American to make sure everything from the deck of an aircraft carrier to the steel on highway guardrails are made in America. \\n\\nBut to compete for the best jobs of the future, we also need to level the playing field with China and other competitors. \\n\\nThat’s why it is so important to pass the Bipartisan Innovation Act sitting in Congress that will make record investments in emerging technologies and American manufacturing. \\n\\nLet me give you one example of why it’s so important to pass it.', metadata={'source': '../../modules/state_of_the_union.txt'}),\n", + " Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \\n\\nLast year COVID-19 kept us apart. This year we are finally together again. \\n\\nTonight, we meet as Democrats Republicans and Independents. But most importantly as Americans. \\n\\nWith a duty to one another to the American people to the Constitution. \\n\\nAnd with an unwavering resolve that freedom will always triumph over tyranny. \\n\\nSix days ago, Russia’s Vladimir Putin sought to shake the foundations of the free world thinking he could make it bend to his menacing ways. But he badly miscalculated. \\n\\nHe thought he could roll into Ukraine and the world would roll over. Instead he met a wall of strength he never imagined. \\n\\nHe met the Ukrainian people. \\n\\nFrom President Zelenskyy to every Ukrainian, their fearlessness, their courage, their determination, inspires the world.', metadata={'source': '../../modules/state_of_the_union.txt'})]" ] }, - "execution_count": 27, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -209,6 +239,29 @@ "result" ] }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[Document(page_content='A chilling portrayal of a totalitarian regime, this dystopian novel offers a bleak vision of a future world dominated by surveillance, propaganda, and thought control. Through the eyes of a disillusioned protagonist, it explores the dangers of totalitarianism and the erosion of individual freedom in a society ruled by fear and oppression.', metadata={'title': '1984', 'author': 'George Orwell', 'year': 1949}),\n", + " Document(page_content='Narrated by a disillusioned teenager, this novel follows his journey of self-discovery and rebellion against the phoniness of the adult world. Through a series of encounters and reflections, it explores themes of alienation, identity, and the search for authenticity in a society marked by conformity and hypocrisy.', metadata={'title': 'The Catcher in the Rye', 'author': 'J.D. Salinger', 'year': 1951}),\n", + " Document(page_content='Set in the English countryside during the early 19th century, this novel follows the lives of the Bennet sisters as they navigate the intricate social hierarchy of their time. Focusing on themes of marriage, class, and societal expectations, the story offers a witty and insightful commentary on the complexities of romantic relationships and the pursuit of happiness.', metadata={'title': 'Pride and Prejudice', 'author': 'Jane Austen', 'year': 1813})]" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result = store.similarity_search(\"dystopia\", k=3, filter=\"year < 2000\")\n", + "result" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -222,23 +275,23 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9181416\n", - "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.91668516\n", - "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9117657\n", - "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.90447474\n", - "{'source': 'docs/docs/modules/state_of_the_union.txt'} - 0.9022917\n" + "{'source': '../../modules/state_of_the_union.txt'} - 0.87391514\n", + "{'source': '../../modules/state_of_the_union.txt'} - 0.8549463\n", + "{'source': '../../modules/state_of_the_union.txt'} - 0.847913\n", + "{'source': '../../modules/state_of_the_union.txt'} - 0.84328896\n", + "{'source': '../../modules/state_of_the_union.txt'} - 0.832347\n" ] } ], "source": [ - "result = store.similarity_search(\"The United States of America\", k=5)\n", + "result = store.similarity_search_with_score(\"The United States of America\", k=5)\n", "\n", "for doc, score in result:\n", " print(f\"{doc.metadata} - {score}\")" @@ -255,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -273,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 33, "metadata": {}, "outputs": [], "source": [ @@ -293,23 +346,16 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 36, "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'vectorCount': 44, 'pendingVectorCount': 0, 'indexSize': 2642412, 'dimension': 1536, 'similarityFunction': 'COSINE'}\n" - ] - }, { "data": { "text/plain": [ - "InfoResult(vector_count=44, pending_vector_count=0, index_size=2642412, dimension=1536, similarity_function='COSINE')" + "InfoResult(vector_count=42, pending_vector_count=0, index_size=6470, dimension=384, similarity_function='COSINE')" ] }, - "execution_count": 32, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -335,7 +381,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.9.6" } }, "nbformat": 4, From 2a49b5d4f048edd22e58a7fadfc8b28cda670841 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Wed, 24 Apr 2024 12:48:17 +0300 Subject: [PATCH 36/41] fix formatting --- .../vectorstores/upstash.py | 42 ++--- .../vectorstores/test_upstash.py | 162 +++++++----------- 2 files changed, 80 insertions(+), 124 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 4c32cafd6f619..3e13ee9f8c891 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -150,7 +150,9 @@ def embeddings(self) -> Optional[Union[Embeddings, bool]]: """Access the query embedding object if available.""" return self._embeddings - def _embed_documents(self, texts: Iterable[str]) -> Union[List[List[float], List[str]]]: + def _embed_documents( + self, texts: Iterable[str] + ) -> Union[List[List[float], List[str]]]: """Embed strings using the embeddings object""" if not self._embeddings: raise ValueError( @@ -159,7 +161,7 @@ def _embed_documents(self, texts: Iterable[str]) -> Union[List[List[float], List ) if isinstance(self._embeddings, Embeddings): return self._embeddings.embed_documents(list(texts)) - + # using self._embeddings is True, Upstash embeddings will be used. # returning list of text as List[str] return list(texts) @@ -173,7 +175,7 @@ def _embed_query(self, text: str) -> Union[List[float], str]: ) if isinstance(self._embeddings, Embeddings): return self._embeddings.embed_query(text) - + # using self._embeddings is True, Upstash embeddings will be used. # returning query as it is return text @@ -421,21 +423,15 @@ def similarity_search_by_vector_with_score( embedding: Union[List[float], str], k: int = 4, filter: Optional[str] = None, - **kwargs: Any + **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" payload = ( - {"data": embedding} - if isinstance(embedding, str) - else {"vector": embedding} + {"data": embedding} if isinstance(embedding, str) else {"vector": embedding} ) results = self._index.query( - **payload, - top_k=k, - include_metadata=True, - filter=filter, - **kwargs + **payload, top_k=k, include_metadata=True, filter=filter, **kwargs ) return self._process_results(results) @@ -450,16 +446,10 @@ async def asimilarity_search_by_vector_with_score( """Return texts whose embedding is closest to the given embedding""" payload = ( - {"data": embedding} - if isinstance(embedding, str) - else {"vector": embedding} + {"data": embedding} if isinstance(embedding, str) else {"vector": embedding} ) results = await self._async_index.query( - **payload, - top_k=k, - include_metadata=True, - filter=filter, - **kwargs + **payload, top_k=k, include_metadata=True, filter=filter, **kwargs ) return self._process_results(results) @@ -562,9 +552,7 @@ def _similarity_search_with_relevance_scores( """ Since Upstash always returns relevance scores, default implementation is used. """ - return self.similarity_search_with_score( - query, k=k, filter=filter, **kwargs - ) + return self.similarity_search_with_score(query, k=k, filter=filter, **kwargs) async def _asimilarity_search_with_relevance_scores( self, @@ -614,7 +602,7 @@ def max_marginal_relevance_search_by_vector( include_vectors=True, include_metadata=True, filter=filter, - **kwargs + **kwargs, ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), @@ -662,7 +650,7 @@ async def amax_marginal_relevance_search_by_vector( include_vectors=True, include_metadata=True, filter=filter, - **kwargs + **kwargs, ) mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), @@ -710,7 +698,7 @@ def max_marginal_relevance_search( fetch_k=fetch_k, lambda_mult=lambda_mult, filter=filter, - **kwargs + **kwargs, ) async def amax_marginal_relevance_search( @@ -747,7 +735,7 @@ async def amax_marginal_relevance_search( fetch_k=fetch_k, lambda_mult=lambda_mult, filter=filter, - **kwargs + **kwargs, ) @classmethod diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index cb06bdbc33ffe..4d9d02c62fc86 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -2,7 +2,7 @@ import os from time import sleep -from typing import List, Union, Dict +from typing import List, Tuple import pytest from langchain_core.documents import Document @@ -15,11 +15,11 @@ @pytest.fixture(scope="function", autouse=True) -def fixture(): +def fixture() -> None: index = Index.from_env() embedding_index = Index( url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], ) index.reset() @@ -29,25 +29,22 @@ def fixture(): wait_for_indexing(embedding_index) -def wait_for_indexing(store: UpstashVectorStore): +def wait_for_indexing(store: UpstashVectorStore) -> None: while store.info().pending_vector_count != 0: # Wait for indexing to complete sleep(0.5) def check_response_with_score( - result: List[Dict[str, Union[Document, float]]], - expected: List[Dict[str, Union[Document, float]]] - ): + result: List[Tuple[Document, float]], + expected: List[Tuple[Document, float]], +) -> None: """ check the result of a search with scores with an expected value scores in result will be rounded by two digits """ - result = list(map( - lambda result: (result[0], round(result[1], 2)), - result - )) + result = list(map(lambda result: (result[0], round(result[1], 2)), result)) assert result == expected @@ -268,6 +265,7 @@ def test_upstash_add_documents_mixed_metadata() -> None: docs, key=lambda d: d.page_content ) + def test_upstash_similarity_search_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -280,30 +278,20 @@ def test_upstash_similarity_search_with_metadata() -> None: store.add_documents(docs, ids=ids) wait_for_indexing(store) - result = store.similarity_search( - query="foo", - k=5, - filter="waldo = 1" - ) + result = store.similarity_search(query="foo", k=5, filter="waldo = 1") assert result == [ Document(page_content="bar", metadata={"waldo": 1}), Document(page_content="baz", metadata={"waldo": 1}), ] - result = store.similarity_search_with_score( - query="foo", - k=5, - filter="waldo = 2" - ) + result = store.similarity_search_with_score(query="foo", k=5, filter="waldo = 2") check_response_with_score( - result, - [ - (Document(page_content='fred', metadata={'waldo': 2}), 0.85) - ] + result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] ) + @pytest.mark.asyncio async def test_upstash_similarity_search_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -317,11 +305,7 @@ async def test_upstash_similarity_search_with_metadata_async() -> None: store.add_documents(docs, ids=ids) wait_for_indexing(store) - result = await store.asimilarity_search( - query="foo", - k=5, - filter="waldo = 1" - ) + result = await store.asimilarity_search(query="foo", k=5, filter="waldo = 1") assert result == [ Document(page_content="bar", metadata={"waldo": 1}), @@ -329,18 +313,14 @@ async def test_upstash_similarity_search_with_metadata_async() -> None: ] result = await store.asimilarity_search_with_score( - query="foo", - k=5, - filter="waldo = 2" + query="foo", k=5, filter="waldo = 2" ) check_response_with_score( - result, - [ - (Document(page_content='fred', metadata={'waldo': 2}), 0.85) - ] + result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] ) + def test_upstash_similarity_search_by_vector_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -356,17 +336,18 @@ def test_upstash_similarity_search_by_vector_with_metadata() -> None: result = store.similarity_search_by_vector_with_score( embedding=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], k=5, - filter="waldo = 1" + filter="waldo = 1", ) check_response_with_score( result, [ - (Document(page_content='bar', metadata={'waldo': 1}), 1.0), - (Document(page_content='baz', metadata={'waldo': 1}), 0.98) - ] + (Document(page_content="bar", metadata={"waldo": 1}), 1.0), + (Document(page_content="baz", metadata={"waldo": 1}), 0.98), + ], ) + @pytest.mark.asyncio async def test_upstash_similarity_search_by_vector_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -383,17 +364,18 @@ async def test_upstash_similarity_search_by_vector_with_metadata_async() -> None result = await store.asimilarity_search_by_vector_with_score( embedding=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], k=5, - filter="waldo = 1" + filter="waldo = 1", ) check_response_with_score( result, [ - (Document(page_content='bar', metadata={'waldo': 1}), 1.0), - (Document(page_content='baz', metadata={'waldo': 1}), 0.98) - ] + (Document(page_content="bar", metadata={"waldo": 1}), 1.0), + (Document(page_content="baz", metadata={"waldo": 1}), 0.98), + ], ) + def test_upstash_max_marginal_relevance_search_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -406,17 +388,14 @@ def test_upstash_max_marginal_relevance_search_with_metadata() -> None: store.add_documents(docs, ids=ids) wait_for_indexing(store) - result = store.max_marginal_relevance_search( - query="foo", - k=3, - filter="waldo = 1" - ) + result = store.max_marginal_relevance_search(query="foo", k=3, filter="waldo = 1") assert result == [ - Document(page_content='bar', metadata={'waldo': 1}), - Document(page_content='baz', metadata={'waldo': 1}) + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), ] + @pytest.mark.asyncio async def test_upstash_max_marginal_relevance_search_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -431,18 +410,16 @@ async def test_upstash_max_marginal_relevance_search_with_metadata_async() -> No wait_for_indexing(store) result = await store.amax_marginal_relevance_search( - query="foo", - k=3, - filter="waldo = 1" + query="foo", k=3, filter="waldo = 1" ) assert result == [ - Document(page_content='bar', metadata={'waldo': 1}), - Document(page_content='baz', metadata={'waldo': 1}) + Document(page_content="bar", metadata={"waldo": 1}), + Document(page_content="baz", metadata={"waldo": 1}), ] -def test_embeddings_configurations(): +def test_embeddings_configurations() -> None: """ test the behavior of the vector store for different `embeddings` parameter values @@ -453,10 +430,7 @@ def test_embeddings_configurations(): assert embedding == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] embedding = store._embed_documents(["doc1", "doc2"]) - assert embedding == [ - [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - ] + assert embedding == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] # case 2: pass False as embedding store = UpstashVectorStore(embedding=False) @@ -465,13 +439,13 @@ def test_embeddings_configurations(): with pytest.raises(ValueError): embedding = store._embed_documents(["doc1", "doc2"]) - + # case 3: pass True as embedding # Upstash embeddings will be used store = UpstashVectorStore( index=Index( url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], ), embedding=True, ) @@ -480,12 +454,12 @@ def test_embeddings_configurations(): embedding = store._embed_documents(["doc1", "doc2"]) assert embedding == ["doc1", "doc2"] -def test_embedding_index(): +def test_embedding_index() -> None: store = UpstashVectorStore( index=Index( url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"] + token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], ), embedding=True, ) @@ -502,34 +476,31 @@ def test_embedding_index(): wait_for_indexing(store) # similarity search - result = store.similarity_search_with_score( - query="eagle", - k=2 - ) + result = store.similarity_search_with_score(query="eagle", k=2) check_response_with_score( result, [ - (Document(page_content='penguin', metadata={'topic': 'bird'}), 0.82), - (Document(page_content='albatros', metadata={'topic': 'bird'}), 0.78) - ] + (Document(page_content="penguin", metadata={"topic": "bird"}), 0.82), + (Document(page_content="albatros", metadata={"topic": "bird"}), 0.78), + ], ) # similarity search with relevance score - result = store.similarity_search_with_relevance_scores( - query="mozart", - k=2 - ) + result = store.similarity_search_with_relevance_scores(query="mozart", k=2) check_response_with_score( result, [ - (Document(page_content='beethoven', metadata={'topic': 'composer'}), 0.88), - (Document(page_content='rachmaninoff', metadata={'topic': 'composer'}), 0.84) - ] + (Document(page_content="beethoven", metadata={"topic": "composer"}), 0.88), + ( + Document(page_content="rachmaninoff", metadata={"topic": "composer"}), + 0.84, + ), + ], ) -@pytest.mark.asyncio -async def test_embedding_index_async(): +@pytest.mark.asyncio +async def test_embedding_index_async() -> None: store = UpstashVectorStore( index_url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], @@ -548,27 +519,24 @@ async def test_embedding_index_async(): wait_for_indexing(store) # similarity search - result = await store.asimilarity_search_with_score( - query="eagle", - k=2 - ) + result = await store.asimilarity_search_with_score(query="eagle", k=2) check_response_with_score( result, [ - (Document(page_content='penguin', metadata={'topic': 'bird'}), 0.82), - (Document(page_content='albatros', metadata={'topic': 'bird'}), 0.78) - ] + (Document(page_content="penguin", metadata={"topic": "bird"}), 0.82), + (Document(page_content="albatros", metadata={"topic": "bird"}), 0.78), + ], ) - + # similarity search with relevance score - result = await store.asimilarity_search_with_relevance_scores( - query="mozart", - k=2 - ) + result = await store.asimilarity_search_with_relevance_scores(query="mozart", k=2) check_response_with_score( result, [ - (Document(page_content='beethoven', metadata={'topic': 'composer'}), 0.88), - (Document(page_content='rachmaninoff', metadata={'topic': 'composer'}), 0.84) - ] + (Document(page_content="beethoven", metadata={"topic": "composer"}), 0.88), + ( + Document(page_content="rachmaninoff", metadata={"topic": "composer"}), + 0.84, + ), + ], ) From bef06e6a2f7323c77ace60266992665392147d47 Mon Sep 17 00:00:00 2001 From: Bagatur Date: Wed, 24 Apr 2024 13:37:56 -0700 Subject: [PATCH 37/41] fmt --- libs/community/langchain_community/vectorstores/upstash.py | 6 +++--- .../community/tests/unit_tests/vectorstores/test_imports.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 3e13ee9f8c891..967bf60c74116 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -33,10 +33,10 @@ class UpstashVectorStore(VectorStore): Example: .. code-block:: python - from langchain_community.vectorstores.upstash import UpstashVectorStore - from langchain_community.embeddings.openai import OpenAIEmbeddings + from langchain_openai import OpenAIEmbeddings + from langchain_community.vectorstores import UpstashVectorStore - embeddings = OpenAIEmbeddings() + embeddings = OpenAIEmbeddings(model="text-embedding-3-large") vectorstore = UpstashVectorStore( embedding=embeddings, index_url="...", diff --git a/libs/community/tests/unit_tests/vectorstores/test_imports.py b/libs/community/tests/unit_tests/vectorstores/test_imports.py index 97a26daa1deb8..15efe9eaff837 100644 --- a/libs/community/tests/unit_tests/vectorstores/test_imports.py +++ b/libs/community/tests/unit_tests/vectorstores/test_imports.py @@ -82,6 +82,7 @@ "TileDB", "TimescaleVector", "Typesense", + "UpstashVectorStore", "USearch", "VDMS", "Vald", From af9d6787b22c2ce2733dab704a6832292e9e9f85 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Sat, 27 Apr 2024 19:29:55 +0300 Subject: [PATCH 38/41] add upstash vcr recordings --- .../test_upstash/test_embedding_index.yaml | 453 ++++++++++++++++++ .../test_embedding_index_async.yaml | 453 ++++++++++++++++++ .../test_embeddings_configurations.yaml | 174 +++++++ .../test_init_from_async_index.yaml | 218 +++++++++ .../test_init_from_credentials.yaml | 218 +++++++++ .../test_init_from_credentials_async.yaml | 218 +++++++++ .../test_upstash/test_init_from_index.yaml | 218 +++++++++ ..._upstash_add_documents_mixed_metadata.yaml | 399 +++++++++++++++ ...est_upstash_add_documents_no_metadata.yaml | 397 +++++++++++++++ ...rginal_relevance_search_with_metadata.yaml | 404 ++++++++++++++++ ..._relevance_search_with_metadata_async.yaml | 404 ++++++++++++++++ .../test_upstash/test_upstash_mmr.yaml | 406 ++++++++++++++++ .../test_upstash/test_upstash_mmr_async.yaml | 406 ++++++++++++++++ .../test_upstash_mmr_by_vector.yaml | 406 ++++++++++++++++ .../test_upstash_mmr_by_vector_async.yaml | 406 ++++++++++++++++ ...larity_search_by_vector_with_metadata.yaml | 403 ++++++++++++++++ ..._search_by_vector_with_metadata_async.yaml | 403 ++++++++++++++++ ...stash_similarity_search_with_metadata.yaml | 449 +++++++++++++++++ ...similarity_search_with_metadata_async.yaml | 449 +++++++++++++++++ .../test_upstash_simple_insert.yaml | 400 ++++++++++++++++ .../test_upstash_simple_insert_async.yaml | 400 ++++++++++++++++ .../test_upstash_with_metadatas.yaml | 402 ++++++++++++++++ .../test_upstash_with_metadatas_async.yaml | 402 ++++++++++++++++ ...st_upstash_with_metadatas_with_scores.yaml | 402 ++++++++++++++++ ...tash_with_metadatas_with_scores_async.yaml | 402 ++++++++++++++++ ...th_metadatas_with_scores_using_vector.yaml | 402 ++++++++++++++++ ...adatas_with_scores_using_vector_async.yaml | 402 ++++++++++++++++ .../vectorstores/test_upstash.py | 62 ++- 28 files changed, 10148 insertions(+), 10 deletions(-) create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml create mode 100644 libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml new file mode 100644 index 0000000000000..866d8ecf39ba1 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml @@ -0,0 +1,453 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:16 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:16 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:16 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:16 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "c3d6c1fc-144a-4550-b0b6-0df30dca528e", "data": "penguin", "metadata": + {"topic": "bird", "text": "penguin"}}, {"id": "2843c257-5a00-41ca-baee-45e6616b2432", + "data": "albatros", "metadata": {"topic": "bird", "text": "albatros"}}, {"id": + "e428e4e9-b6d1-4ee6-a240-3825c6a6d040", "data": "beethoven", "metadata": {"topic": + "composer", "text": "beethoven"}}, {"id": "0c5ae333-d55d-42d3-bf44-75df6519b227", + "data": "rachmaninoff", "metadata": {"topic": "composer", "text": "rachmaninoff"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '492' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/upsert-data + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:17 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:17 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:17 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:18 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": + "", "data": "eagle"}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"c3d6c1fc-144a-4550-b0b6-0df30dca528e\",\n + \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n + \ }, {\n \"id\" : \"2843c257-5a00-41ca-baee-45e6616b2432\",\n \"score\" + : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '288' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:18 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": + "", "data": "mozart"}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '93' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"e428e4e9-b6d1-4ee6-a240-3825c6a6d040\",\n + \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n + \ }, {\n \"id\" : \"0c5ae333-d55d-42d3-bf44-75df6519b227\",\n \"score\" + : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '304' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:18 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml new file mode 100644 index 0000000000000..2c4855b1ff49c --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml @@ -0,0 +1,453 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:18 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:19 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:19 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:19 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "c91b9d1b-4b1e-4223-bf88-5a6711bd9648", "data": "penguin", "metadata": + {"topic": "bird", "text": "penguin"}}, {"id": "baf22a55-e3b8-47f1-a43a-c5c6eb41d53d", + "data": "albatros", "metadata": {"topic": "bird", "text": "albatros"}}, {"id": + "0c1f7416-625e-4d19-b18b-79e229fdca42", "data": "beethoven", "metadata": {"topic": + "composer", "text": "beethoven"}}, {"id": "ec613f2b-2bb8-430a-88bf-7ed374c201b1", + "data": "rachmaninoff", "metadata": {"topic": "composer", "text": "rachmaninoff"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '492' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/upsert-data + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:19 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:19 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:20 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '158' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:20 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": + "", "data": "eagle"}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"c91b9d1b-4b1e-4223-bf88-5a6711bd9648\",\n + \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n + \ }, {\n \"id\" : \"baf22a55-e3b8-47f1-a43a-c5c6eb41d53d\",\n \"score\" + : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '288' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:20 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": + "", "data": "mozart"}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '93' + content-type: + - application/json + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"0c1f7416-625e-4d19-b18b-79e229fdca42\",\n + \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n + \ }, {\n \"id\" : \"ec613f2b-2bb8-430a-88bf-7ed374c201b1\",\n \"score\" + : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '304' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:21 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml new file mode 100644 index 0000000000000..1b6918d19a408 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml @@ -0,0 +1,174 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:15 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:15 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:15 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:16 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml new file mode 100644 index 0000000000000..7d71e20044031 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml @@ -0,0 +1,218 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:54 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:54 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:54 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:54 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml new file mode 100644 index 0000000000000..f772c70c8f40a --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml @@ -0,0 +1,218 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:54 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:55 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:55 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:55 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:55 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml new file mode 100644 index 0000000000000..7ce2a3d49727e --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml @@ -0,0 +1,218 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:55 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:56 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:56 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:56 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:56 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml new file mode 100644 index 0000000000000..04603565b86ef --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml @@ -0,0 +1,218 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:53 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml new file mode 100644 index 0000000000000..6c6a36be651d6 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml @@ -0,0 +1,399 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"baz": 1, "text": "bar"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '218' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 2,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:59 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 2,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:00 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 4, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"0\",\n \"score\" : 1.0,\n + \ \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" : \"1\",\n \"score\" + : 0.97434163,\n \"metadata\" : {\"baz\":1,\"text\":\"bar\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '182' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml new file mode 100644 index 0000000000000..c593713ee6258 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml @@ -0,0 +1,397 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:56 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:57 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:57 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:57 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "00a18513-7630-4a38-89be-dbea501b2d2d", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '139' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:57 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 1,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:57 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 1,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:58 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:58 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 4, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"00a18513-7630-4a38-89be-dbea501b2d2d\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '128' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:58 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml new file mode 100644 index 0000000000000..bb8fbe25850c0 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml @@ -0,0 +1,404 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:11 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:12 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:12 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '339' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml new file mode 100644 index 0000000000000..cfa31240c2faf --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml @@ -0,0 +1,404 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:13 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:14 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:14 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:15 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '339' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:15 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml new file mode 100644 index 0000000000000..09b2b3e0b0cbd --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml @@ -0,0 +1,406 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:43 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:43 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:43 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:43 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "2596d017-3ece-4f78-8298-317f42845a95", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "78c5c468-6b24-4fc1-b85e-aa3da1442187", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "b5e48d09-e77a-4a37-b5e2-3c7b2f1d3b58", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:44 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:44 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:44 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:45 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"2596d017-3ece-4f78-8298-317f42845a95\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"78c5c468-6b24-4fc1-b85e-aa3da1442187\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"text\":\"bar\"}\n }, {\n \"id\" : \"b5e48d09-e77a-4a37-b5e2-3c7b2f1d3b58\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '567' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:45 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml new file mode 100644 index 0000000000000..db2e172672ccc --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml @@ -0,0 +1,406 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:45 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:45 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:46 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:46 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "a9af95ed-b0f7-4ea9-a7bf-bc1224cc2504", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "5e1802fb-31e3-4424-840f-25da228f7a07", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "ef9e3286-0d28-42bc-aaed-faeed7a1c9cd", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:46 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:46 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:47 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:47 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"a9af95ed-b0f7-4ea9-a7bf-bc1224cc2504\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"5e1802fb-31e3-4424-840f-25da228f7a07\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"text\":\"bar\"}\n }, {\n \"id\" : \"ef9e3286-0d28-42bc-aaed-faeed7a1c9cd\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '567' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:47 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml new file mode 100644 index 0000000000000..ab26a04143d2a --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml @@ -0,0 +1,406 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:48 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:48 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:48 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:48 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "a087b72e-906f-4724-a867-4af800e67052", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "f561d2fb-113f-44de-8f97-133984e195da", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "0bb4529a-9431-49d8-ba5b-4af6813e4435", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:49 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:49 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:49 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:50 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"a087b72e-906f-4724-a867-4af800e67052\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"f561d2fb-113f-44de-8f97-133984e195da\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"text\":\"bar\"}\n }, {\n \"id\" : \"0bb4529a-9431-49d8-ba5b-4af6813e4435\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '567' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:50 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml new file mode 100644 index 0000000000000..b7b43bd43a273 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml @@ -0,0 +1,406 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:50 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:50 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:50 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:51 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "cda72878-0b62-4790-a565-e5b3ec2f62c4", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "7246c7a9-9f83-4867-a0a7-b8e68358afc4", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "59ef5dfa-b434-4bec-892e-9f18ac4bed9f", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:51 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:51 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:51 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:52 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"cda72878-0b62-4790-a565-e5b3ec2f62c4\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"7246c7a9-9f83-4867-a0a7-b8e68358afc4\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"text\":\"bar\"}\n }, {\n \"id\" : \"59ef5dfa-b434-4bec-892e-9f18ac4bed9f\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '567' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:52 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml new file mode 100644 index 0000000000000..cacf31e686029 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml @@ -0,0 +1,403 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:06 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:06 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:06 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:06 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:07 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:07 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:07 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '194' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml new file mode 100644 index 0000000000000..e80434fc2e120 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml @@ -0,0 +1,403 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:08 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:09 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:09 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:09 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:10 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '194' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:10 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml new file mode 100644 index 0000000000000..176979c3c8a01 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml @@ -0,0 +1,449 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:01 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:02 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:02 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:02 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:03 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '201' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:03 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n + \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:03 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml new file mode 100644 index 0000000000000..b80fb883425d9 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml @@ -0,0 +1,449 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:03 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:03 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:04 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:04 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], + "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"waldo": 1, "text": "bar"}}, {"id": "3", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"waldo": + 1, "text": "baz"}}, {"id": "4", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 3.0], "metadata": {"waldo": 2, "text": "fred"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '453' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:04 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:04 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:05 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:05 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '201' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:05 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": + "waldo = 2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '146' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n + \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '110' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:45:06 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml new file mode 100644 index 0000000000000..7a64df116cea7 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml @@ -0,0 +1,400 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:24 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:24 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:24 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:24 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "03f31e48-b455-4d3f-9b75-80cd8fa5be4b", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "cc432a24-a3c7-47e3-a806-399c7dde2a92", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "08a56f3c-c711-4329-95cd-8516e2f05df3", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:25 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:25 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:25 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:26 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"03f31e48-b455-4d3f-9b75-80cd8fa5be4b\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '128' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:26 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml new file mode 100644 index 0000000000000..4538ff52dc27c --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml @@ -0,0 +1,400 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:26 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:27 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:27 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:27 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "e087e36e-79c3-4a54-bd2a-97626f9a6672", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "864b4e8d-7b2b-4e3b-8295-9bc3d8a3e84b", + "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": + "bar"}}, {"id": "ea52dce9-09f5-44a3-aa2a-17c6074f0a93", "vector": [1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '417' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:27 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:27 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:28 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:28 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"e087e36e-79c3-4a54-bd2a-97626f9a6672\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '128' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:28 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml new file mode 100644 index 0000000000000..9d50448bf0725 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "dd2765fb-75dd-4cab-bf39-e0f2f2c7efd8", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "4416d38f-3bd5-496c-a15a-ccfaed29e26f", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "608ded88-6e6d-45bb-b433-7f1f65d5e500", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:29 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:30 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"dd2765fb-75dd-4cab-bf39-e0f2f2c7efd8\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml new file mode 100644 index 0000000000000..4a01e6cec10ad --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:31 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "dc7bf301-074f-482d-90ca-e5db2aaf7856", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "c2aa384e-7ab9-44c8-a67a-19d2f3e005ec", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "ba09467b-6d64-48a4-a7eb-a7f1d18d29a2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:32 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:32 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:32 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:33 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"dc7bf301-074f-482d-90ca-e5db2aaf7856\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:33 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml new file mode 100644 index 0000000000000..9aa30e1f02f14 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:33 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:34 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:34 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:34 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "e8719d31-0b3a-4882-81ae-74ea7d362054", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "7ec8a1b1-a120-4cd1-88fa-c74510da1f57", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "0d87b9db-6081-45f6-a97f-8874c8980fee", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:34 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:34 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:35 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:35 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"e8719d31-0b3a-4882-81ae-74ea7d362054\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:35 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml new file mode 100644 index 0000000000000..3f0b4ed9a6933 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "ecbee7c1-f349-4647-8058-8d4a3c21f3d6", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "e0a194f3-92fd-40ba-a5fd-892f075d6e11", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "f91cf846-2f1a-4587-9713-b25815adcdc5", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:36 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:37 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:38 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"ecbee7c1-f349-4647-8058-8d4a3c21f3d6\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:38 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml new file mode 100644 index 0000000000000..5542bec8c9f20 --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:38 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:38 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:38 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:39 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "cad5b766-d164-4bd8-856d-1d9558483ca1", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "ff046a51-4b15-4c11-a084-013c5eebde7c", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "2cdb2f17-2e5f-4dc8-9d14-cd8642be4b69", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:39 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:39 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:39 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:40 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"cad5b766-d164-4bd8-856d-1d9558483ca1\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:40 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml new file mode 100644 index 0000000000000..d03f46bdb820f --- /dev/null +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml @@ -0,0 +1,402 @@ +interactions: +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:40 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:41 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:41 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - thankful-dane-25695-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://thankful-dane-25695-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:41 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '[{"id": "3c3699b1-fded-4d20-add3-aeed630f3894", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, + {"id": "5324945d-39c4-4a40-a4cf-80b28a0e993e", "vector": [1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": + "e425444c-d555-4b9f-877d-e04914551342", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '456' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert + response: + body: + string: "{\n \"result\" : \"Success\"\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '26' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:41 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:41 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:42 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '0' + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/info + response: + body: + string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '154' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:42 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": + "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' + headers: + User-Agent: + - User-Agent-DUMMY + accept: + - '*/*' + accept-encoding: + - gzip, deflate + authorization: + - authorization-DUMMY + connection: + - keep-alive + content-length: + - '137' + content-type: + - application/json + host: + - fond-mutt-96644-eu1-vector.upstash.io + upstash-telemetry-platform: + - unknown + upstash-telemetry-runtime: + - python@v3.9.19 + upstash-telemetry-sdk: + - upstash-vector-py@v0.3.1 + method: POST + uri: https://fond-mutt-96644-eu1-vector.upstash.io/query + response: + body: + string: "{\n \"result\" : [ {\n \"id\" : \"3c3699b1-fded-4d20-add3-aeed630f3894\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" + headers: + Connection: + - keep-alive + Content-Length: + - '139' + Content-Type: + - application/json + Date: + - Sat, 27 Apr 2024 21:44:43 GMT + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 4d9d02c62fc86..a378713a5041a 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -6,16 +6,30 @@ import pytest from langchain_core.documents import Document -from upstash_vector import AsyncIndex, Index from langchain_community.vectorstores.upstash import UpstashVectorStore from tests.integration_tests.vectorstores.fake_embeddings import ( FakeEmbeddings, ) +# to fix the following error in test with vcr and asyncio +# +# RuntimeError: asyncio.run() cannot be called from a running event loop +import nest_asyncio +nest_asyncio.apply() + + +@pytest.fixture(scope="module") +def vcr_cassette_dir(request): + # save under cassettes/test_upstash/{item}.yaml + return os.path.join("cassettes", "test_upstash") + @pytest.fixture(scope="function", autouse=True) def fixture() -> None: + + from upstash_vector import Index + index = Index.from_env() embedding_index = Index( url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], @@ -49,6 +63,7 @@ def check_response_with_score( assert result == expected +@pytest.mark.vcr() def test_upstash_simple_insert() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -58,6 +73,7 @@ def test_upstash_simple_insert() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_simple_insert_async() -> None: """Test end to end construction and search.""" @@ -68,6 +84,7 @@ async def test_upstash_simple_insert_async() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.vcr() def test_upstash_with_metadatas() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -82,6 +99,7 @@ def test_upstash_with_metadatas() -> None: assert output == [Document(page_content="foo", metadata={"page": "0"})] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_with_metadatas_async() -> None: """Test end to end construction and search.""" @@ -97,6 +115,7 @@ async def test_upstash_with_metadatas_async() -> None: assert output == [Document(page_content="foo", metadata={"page": "0"})] +@pytest.mark.vcr() def test_upstash_with_metadatas_with_scores() -> None: """Test end to end construction and scored search.""" texts = ["foo", "bar", "baz"] @@ -111,6 +130,7 @@ def test_upstash_with_metadatas_with_scores() -> None: assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_with_metadatas_with_scores_async() -> None: """Test end to end construction and scored search.""" @@ -126,6 +146,7 @@ async def test_upstash_with_metadatas_with_scores_async() -> None: assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.vcr() def test_upstash_with_metadatas_with_scores_using_vector() -> None: """Test end to end construction and scored search, using embedding vector.""" texts = ["foo", "bar", "baz"] @@ -143,6 +164,7 @@ def test_upstash_with_metadatas_with_scores_using_vector() -> None: assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_with_metadatas_with_scores_using_vector_async() -> None: """Test end to end construction and scored search, using embedding vector.""" @@ -163,6 +185,7 @@ async def test_upstash_with_metadatas_with_scores_using_vector_async() -> None: assert output == [(Document(page_content="foo", metadata={"page": "0"}), 1.0)] +@pytest.mark.vcr() def test_upstash_mmr() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -172,6 +195,7 @@ def test_upstash_mmr() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_mmr_async() -> None: """Test end to end construction and search.""" @@ -182,6 +206,7 @@ async def test_upstash_mmr_async() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.vcr() def test_upstash_mmr_by_vector() -> None: """Test end to end construction and search.""" texts = ["foo", "bar", "baz"] @@ -192,7 +217,7 @@ def test_upstash_mmr_by_vector() -> None: output = store.max_marginal_relevance_search_by_vector(embedded_query, k=1) assert output == [Document(page_content="foo")] - +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_mmr_by_vector_async() -> None: """Test end to end construction and search.""" @@ -205,7 +230,11 @@ async def test_upstash_mmr_by_vector_async() -> None: assert output == [Document(page_content="foo")] +@pytest.mark.vcr() def test_init_from_index() -> None: + + from upstash_vector import Index + index = Index.from_env() store = UpstashVectorStore(index=index) @@ -213,8 +242,12 @@ def test_init_from_index() -> None: assert store.info() is not None +@pytest.mark.vcr() @pytest.mark.asyncio async def test_init_from_async_index() -> None: + + from upstash_vector import AsyncIndex + index = AsyncIndex.from_env() store = UpstashVectorStore(async_index=index) @@ -222,6 +255,7 @@ async def test_init_from_async_index() -> None: assert await store.ainfo() is not None +@pytest.mark.vcr() def test_init_from_credentials() -> None: store = UpstashVectorStore( index_url=os.environ["UPSTASH_VECTOR_REST_URL"], @@ -231,6 +265,7 @@ def test_init_from_credentials() -> None: assert store.info() is not None +@pytest.mark.vcr() @pytest.mark.asyncio async def test_init_from_credentials_async() -> None: store = UpstashVectorStore( @@ -241,6 +276,7 @@ async def test_init_from_credentials_async() -> None: assert await store.ainfo() is not None +@pytest.mark.vcr() def test_upstash_add_documents_no_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) store.add_documents([Document(page_content="foo")]) @@ -250,6 +286,7 @@ def test_upstash_add_documents_no_metadata() -> None: assert search == [Document(page_content="foo")] +@pytest.mark.vcr() def test_upstash_add_documents_mixed_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -266,6 +303,7 @@ def test_upstash_add_documents_mixed_metadata() -> None: ) +@pytest.mark.vcr() def test_upstash_similarity_search_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -292,6 +330,7 @@ def test_upstash_similarity_search_with_metadata() -> None: ) +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_similarity_search_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -321,6 +360,7 @@ async def test_upstash_similarity_search_with_metadata_async() -> None: ) +@pytest.mark.vcr() def test_upstash_similarity_search_by_vector_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -348,6 +388,7 @@ def test_upstash_similarity_search_by_vector_with_metadata() -> None: ) +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_similarity_search_by_vector_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -376,6 +417,7 @@ async def test_upstash_similarity_search_by_vector_with_metadata_async() -> None ) +@pytest.mark.vcr() def test_upstash_max_marginal_relevance_search_with_metadata() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) docs = [ @@ -396,6 +438,7 @@ def test_upstash_max_marginal_relevance_search_with_metadata() -> None: ] +@pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_max_marginal_relevance_search_with_metadata_async() -> None: store = UpstashVectorStore(embedding=FakeEmbeddings()) @@ -419,6 +462,7 @@ async def test_upstash_max_marginal_relevance_search_with_metadata_async() -> No ] +@pytest.mark.vcr() def test_embeddings_configurations() -> None: """ test the behavior of the vector store for different `embeddings` parameter @@ -443,10 +487,8 @@ def test_embeddings_configurations() -> None: # case 3: pass True as embedding # Upstash embeddings will be used store = UpstashVectorStore( - index=Index( - url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], - ), + index_url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], embedding=True, ) embedding = store._embed_query("query") @@ -455,12 +497,11 @@ def test_embeddings_configurations() -> None: assert embedding == ["doc1", "doc2"] +@pytest.mark.vcr() def test_embedding_index() -> None: store = UpstashVectorStore( - index=Index( - url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], - ), + index_url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], embedding=True, ) @@ -499,6 +540,7 @@ def test_embedding_index() -> None: ) +@pytest.mark.vcr() @pytest.mark.asyncio async def test_embedding_index_async() -> None: store = UpstashVectorStore( From 94eaa9a0796113c514015597c5e317a19fa82039 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Sun, 28 Apr 2024 00:57:47 +0300 Subject: [PATCH 39/41] formatting --- .../vectorstores/upstash.py | 133 ++++++++++++------ .../vectorstores/test_upstash.py | 76 +++++----- 2 files changed, 134 insertions(+), 75 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/upstash.py b/libs/community/langchain_community/vectorstores/upstash.py index 967bf60c74116..96bcc6e4e5132 100644 --- a/libs/community/langchain_community/vectorstores/upstash.py +++ b/libs/community/langchain_community/vectorstores/upstash.py @@ -16,6 +16,7 @@ if TYPE_CHECKING: from upstash_vector import AsyncIndex, Index + from upstash_vector.types import InfoResult logger = logging.getLogger(__name__) @@ -146,13 +147,13 @@ def __init__( self._text_key = text_key @property - def embeddings(self) -> Optional[Union[Embeddings, bool]]: + def embeddings(self) -> Optional[Union[Embeddings, bool]]: # type: ignore """Access the query embedding object if available.""" return self._embeddings def _embed_documents( self, texts: Iterable[str] - ) -> Union[List[List[float], List[str]]]: + ) -> Union[List[List[float]], List[str]]: """Embed strings using the embeddings object""" if not self._embeddings: raise ValueError( @@ -182,10 +183,11 @@ def _embed_query(self, text: str) -> Union[List[float], str]: def add_documents( self, - documents: Iterable[Document], + documents: List[Document], ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, + **kwargs: Any, ) -> List[str]: """ Get the embeddings for the documents and add them to the vectorstore. @@ -214,6 +216,7 @@ def add_documents( batch_size=batch_size, ids=ids, embedding_chunk_size=embedding_chunk_size, + **kwargs, ) async def aadd_documents( @@ -222,6 +225,7 @@ async def aadd_documents( ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, + **kwargs: Any, ) -> List[str]: """ Get the embeddings for the documents and add them to the vectorstore. @@ -250,6 +254,7 @@ async def aadd_documents( ids=ids, batch_size=batch_size, embedding_chunk_size=embedding_chunk_size, + **kwargs, ) def add_texts( @@ -259,6 +264,7 @@ def add_texts( ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, + **kwargs: Any, ) -> List[str]: """ Get the embeddings for the texts and add them to the vectorstore. @@ -302,7 +308,7 @@ def add_texts( for batch in batch_iterate( batch_size, zip(chunk_ids, embeddings, chunk_metadatas) ): - self._index.upsert(vectors=batch) + self._index.upsert(vectors=batch, **kwargs) return ids @@ -313,6 +319,7 @@ async def aadd_texts( ids: Optional[List[str]] = None, batch_size: int = 32, embedding_chunk_size: int = 1000, + **kwargs: Any, ) -> List[str]: """ Get the embeddings for the texts and add them to the vectorstore. @@ -356,7 +363,7 @@ async def aadd_texts( for batch in batch_iterate( batch_size, zip(chunk_ids, embeddings, chunk_metadatas) ): - await self._async_index.upsert(vectors=batch) + await self._async_index.upsert(vectors=batch, **kwargs) return ids @@ -427,12 +434,20 @@ def similarity_search_by_vector_with_score( ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" - payload = ( - {"data": embedding} if isinstance(embedding, str) else {"vector": embedding} - ) - results = self._index.query( - **payload, top_k=k, include_metadata=True, filter=filter, **kwargs - ) + filter = filter or "" + + if isinstance(embedding, str): + results = self._index.query( + data=embedding, top_k=k, include_metadata=True, filter=filter, **kwargs + ) + else: + results = self._index.query( + vector=embedding, + top_k=k, + include_metadata=True, + filter=filter, + **kwargs, + ) return self._process_results(results) @@ -445,12 +460,20 @@ async def asimilarity_search_by_vector_with_score( ) -> List[Tuple[Document, float]]: """Return texts whose embedding is closest to the given embedding""" - payload = ( - {"data": embedding} if isinstance(embedding, str) else {"vector": embedding} - ) - results = await self._async_index.query( - **payload, top_k=k, include_metadata=True, filter=filter, **kwargs - ) + filter = filter or "" + + if isinstance(embedding, str): + results = await self._async_index.query( + data=embedding, top_k=k, include_metadata=True, filter=filter, **kwargs + ) + else: + results = await self._async_index.query( + vector=embedding, + top_k=k, + include_metadata=True, + filter=filter, + **kwargs, + ) return self._process_results(results) @@ -570,7 +593,7 @@ async def _asimilarity_search_with_relevance_scores( def max_marginal_relevance_search_by_vector( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, @@ -596,14 +619,25 @@ def max_marginal_relevance_search_by_vector( List of Documents selected by maximal marginal relevance. """ assert isinstance(self.embeddings, Embeddings) - results = self._index.query( - vector=embedding, - top_k=fetch_k, - include_vectors=True, - include_metadata=True, - filter=filter, - **kwargs, - ) + if isinstance(embedding, str): + results = self._index.query( + data=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + filter=filter or "", + **kwargs, + ) + else: + results = self._index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + filter=filter or "", + **kwargs, + ) + mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), [item.vector for item in results], @@ -612,13 +646,13 @@ def max_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore for metadata in selected ] async def amax_marginal_relevance_search_by_vector( self, - embedding: List[float], + embedding: Union[List[float], str], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, @@ -644,14 +678,25 @@ async def amax_marginal_relevance_search_by_vector( List of Documents selected by maximal marginal relevance. """ assert isinstance(self.embeddings, Embeddings) - results = await self._async_index.query( - vector=embedding, - top_k=fetch_k, - include_vectors=True, - include_metadata=True, - filter=filter, - **kwargs, - ) + if isinstance(embedding, str): + results = await self._async_index.query( + data=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + filter=filter or "", + **kwargs, + ) + else: + results = await self._async_index.query( + vector=embedding, + top_k=fetch_k, + include_vectors=True, + include_metadata=True, + filter=filter or "", + **kwargs, + ) + mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), [item.vector for item in results], @@ -660,7 +705,7 @@ async def amax_marginal_relevance_search_by_vector( ) selected = [results[i].metadata for i in mmr_selected] return [ - Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore since include_metadata=True + Document(page_content=metadata.pop((self._text_key)), metadata=metadata) # type: ignore for metadata in selected ] @@ -752,6 +797,7 @@ def from_texts( async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, index_token: Optional[str] = None, + **kwargs: Any, ) -> UpstashVectorStore: """Create a new UpstashVectorStore from a list of texts. @@ -773,6 +819,7 @@ def from_texts( async_index=async_index, index_url=index_url, index_token=index_token, + **kwargs, ) vector_store.add_texts( @@ -798,6 +845,7 @@ async def afrom_texts( async_index: Optional[AsyncIndex] = None, index_url: Optional[str] = None, index_token: Optional[str] = None, + **kwargs: Any, ) -> UpstashVectorStore: """Create a new UpstashVectorStore from a list of texts. @@ -819,6 +867,7 @@ async def afrom_texts( async_index=async_index, index_url=index_url, index_token=index_token, + **kwargs, ) await vector_store.aadd_texts( @@ -834,7 +883,8 @@ def delete( self, ids: Optional[List[str]] = None, delete_all: Optional[bool] = None, - batch_size=1000, + batch_size: Optional[int] = 1000, + **kwargs: Any, ) -> None: """Delete by vector IDs @@ -859,7 +909,8 @@ async def adelete( self, ids: Optional[List[str]] = None, delete_all: Optional[bool] = None, - batch_size=1000, + batch_size: Optional[int] = 1000, + **kwargs: Any, ) -> None: """Delete by vector IDs @@ -880,7 +931,7 @@ async def adelete( return None - def info(self): + def info(self) -> InfoResult: """Get statistics about the index. Returns: @@ -892,7 +943,7 @@ def info(self): """ return self._index.info() - async def ainfo(self): + async def ainfo(self) -> InfoResult: """Get statistics about the index. Returns: diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index a378713a5041a..2c2586825fbc3 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -2,8 +2,12 @@ import os from time import sleep -from typing import List, Tuple +from typing import TYPE_CHECKING, List, Tuple, Union +# to fix the following error in test with vcr and asyncio +# +# RuntimeError: asyncio.run() cannot be called from a running event loop +import nest_asyncio import pytest from langchain_core.documents import Document @@ -12,22 +16,20 @@ FakeEmbeddings, ) -# to fix the following error in test with vcr and asyncio -# -# RuntimeError: asyncio.run() cannot be called from a running event loop -import nest_asyncio nest_asyncio.apply() +if TYPE_CHECKING: + from upstash_vector import Index + @pytest.fixture(scope="module") -def vcr_cassette_dir(request): +def vcr_cassette_dir() -> str: # save under cassettes/test_upstash/{item}.yaml return os.path.join("cassettes", "test_upstash") @pytest.fixture(scope="function", autouse=True) def fixture() -> None: - from upstash_vector import Index index = Index.from_env() @@ -43,7 +45,7 @@ def fixture() -> None: wait_for_indexing(embedding_index) -def wait_for_indexing(store: UpstashVectorStore) -> None: +def wait_for_indexing(store: Union[Index, UpstashVectorStore]) -> None: while store.info().pending_vector_count != 0: # Wait for indexing to complete sleep(0.5) @@ -217,6 +219,7 @@ def test_upstash_mmr_by_vector() -> None: output = store.max_marginal_relevance_search_by_vector(embedded_query, k=1) assert output == [Document(page_content="foo")] + @pytest.mark.vcr() @pytest.mark.asyncio async def test_upstash_mmr_by_vector_async() -> None: @@ -232,7 +235,6 @@ async def test_upstash_mmr_by_vector_async() -> None: @pytest.mark.vcr() def test_init_from_index() -> None: - from upstash_vector import Index index = Index.from_env() @@ -245,7 +247,6 @@ def test_init_from_index() -> None: @pytest.mark.vcr() @pytest.mark.asyncio async def test_init_from_async_index() -> None: - from upstash_vector import AsyncIndex index = AsyncIndex.from_env() @@ -323,10 +324,12 @@ def test_upstash_similarity_search_with_metadata() -> None: Document(page_content="baz", metadata={"waldo": 1}), ] - result = store.similarity_search_with_score(query="foo", k=5, filter="waldo = 2") + search_result = store.similarity_search_with_score( + query="foo", k=5, filter="waldo = 2" + ) check_response_with_score( - result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] + search_result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] ) @@ -351,12 +354,12 @@ async def test_upstash_similarity_search_with_metadata_async() -> None: Document(page_content="baz", metadata={"waldo": 1}), ] - result = await store.asimilarity_search_with_score( + search_result = await store.asimilarity_search_with_score( query="foo", k=5, filter="waldo = 2" ) check_response_with_score( - result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] + search_result, [(Document(page_content="fred", metadata={"waldo": 2}), 0.85)] ) @@ -470,19 +473,22 @@ def test_embeddings_configurations() -> None: """ # case 1: use FakeEmbeddings, a subclass of Embeddings store = UpstashVectorStore(embedding=FakeEmbeddings()) - embedding = store._embed_query("query") - assert embedding == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] + query_embedding = store._embed_query("query") + assert query_embedding == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0] - embedding = store._embed_documents(["doc1", "doc2"]) - assert embedding == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] + document_embedding = store._embed_documents(["doc1", "doc2"]) + assert document_embedding == [ + [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + ] # case 2: pass False as embedding store = UpstashVectorStore(embedding=False) with pytest.raises(ValueError): - embedding = store._embed_query("query") + query_embedding = store._embed_query("query") with pytest.raises(ValueError): - embedding = store._embed_documents(["doc1", "doc2"]) + document_embedding = store._embed_documents(["doc1", "doc2"]) # case 3: pass True as embedding # Upstash embeddings will be used @@ -491,10 +497,10 @@ def test_embeddings_configurations() -> None: index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], embedding=True, ) - embedding = store._embed_query("query") - assert embedding == "query" - embedding = store._embed_documents(["doc1", "doc2"]) - assert embedding == ["doc1", "doc2"] + query_embedding = store._embed_query("query") + assert query_embedding == "query" + document_embedding = store._embed_documents(["doc1", "doc2"]) + assert document_embedding == ["doc1", "doc2"] @pytest.mark.vcr() @@ -506,7 +512,7 @@ def test_embedding_index() -> None: ) # add documents - result = store.add_documents( + store.add_documents( [ Document(page_content="penguin", metadata={"topic": "bird"}), Document(page_content="albatros", metadata={"topic": "bird"}), @@ -517,9 +523,9 @@ def test_embedding_index() -> None: wait_for_indexing(store) # similarity search - result = store.similarity_search_with_score(query="eagle", k=2) + search_result = store.similarity_search_with_score(query="eagle", k=2) check_response_with_score( - result, + search_result, [ (Document(page_content="penguin", metadata={"topic": "bird"}), 0.82), (Document(page_content="albatros", metadata={"topic": "bird"}), 0.78), @@ -527,9 +533,9 @@ def test_embedding_index() -> None: ) # similarity search with relevance score - result = store.similarity_search_with_relevance_scores(query="mozart", k=2) + search_result = store.similarity_search_with_relevance_scores(query="mozart", k=2) check_response_with_score( - result, + search_result, [ (Document(page_content="beethoven", metadata={"topic": "composer"}), 0.88), ( @@ -550,7 +556,7 @@ async def test_embedding_index_async() -> None: ) # add documents - result = await store.aadd_documents( + await store.aadd_documents( [ Document(page_content="penguin", metadata={"topic": "bird"}), Document(page_content="albatros", metadata={"topic": "bird"}), @@ -561,9 +567,9 @@ async def test_embedding_index_async() -> None: wait_for_indexing(store) # similarity search - result = await store.asimilarity_search_with_score(query="eagle", k=2) + search_result = await store.asimilarity_search_with_score(query="eagle", k=2) check_response_with_score( - result, + search_result, [ (Document(page_content="penguin", metadata={"topic": "bird"}), 0.82), (Document(page_content="albatros", metadata={"topic": "bird"}), 0.78), @@ -571,9 +577,11 @@ async def test_embedding_index_async() -> None: ) # similarity search with relevance score - result = await store.asimilarity_search_with_relevance_scores(query="mozart", k=2) + search_result = await store.asimilarity_search_with_relevance_scores( + query="mozart", k=2 + ) check_response_with_score( - result, + search_result, [ (Document(page_content="beethoven", metadata={"topic": "composer"}), 0.88), ( From b819fab8539136980a788a1b0f521c2527bebc94 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Sun, 28 Apr 2024 01:21:40 +0300 Subject: [PATCH 40/41] rm nest_asyncio.apply call I had included nest_asyncio.apply in the test to stop an error I was getting: "RuntimeError: asyncio.run() cannot be called from a running event loop" But nest_asyncio couldn't be imported in CI so I had to remove it. To fix the error, I had to downgrade vcrpy to 4.3.0 and urllib3 to 1.26.18 according to poetry.lock. This solved the error I was getting. This also meant that the cassettes changed. Updating them aswell. --- .../test_upstash/test_embedding_index.yaml | 150 ++++++++---------- .../test_embedding_index_async.yaml | 150 ++++++++---------- .../test_embeddings_configurations.yaml | 48 +++--- .../test_init_from_async_index.yaml | 62 +++----- .../test_init_from_credentials.yaml | 62 +++----- .../test_init_from_credentials_async.yaml | 62 +++----- .../test_upstash/test_init_from_index.yaml | 62 +++----- ..._upstash_add_documents_mixed_metadata.yaml | 120 ++++++-------- ...est_upstash_add_documents_no_metadata.yaml | 120 ++++++-------- ...rginal_relevance_search_with_metadata.yaml | 124 +++++++-------- ..._relevance_search_with_metadata_async.yaml | 124 +++++++-------- .../test_upstash/test_upstash_mmr.yaml | 136 +++++++--------- .../test_upstash/test_upstash_mmr_async.yaml | 136 +++++++--------- .../test_upstash_mmr_by_vector.yaml | 136 +++++++--------- .../test_upstash_mmr_by_vector_async.yaml | 136 +++++++--------- ...larity_search_by_vector_with_metadata.yaml | 121 ++++++-------- ..._search_by_vector_with_metadata_async.yaml | 121 ++++++-------- ...stash_similarity_search_with_metadata.yaml | 134 +++++++--------- ...similarity_search_with_metadata_async.yaml | 134 +++++++--------- .../test_upstash_simple_insert.yaml | 124 +++++++-------- .../test_upstash_simple_insert_async.yaml | 124 +++++++-------- .../test_upstash_with_metadatas.yaml | 126 +++++++-------- .../test_upstash_with_metadatas_async.yaml | 126 +++++++-------- ...st_upstash_with_metadatas_with_scores.yaml | 126 +++++++-------- ...tash_with_metadatas_with_scores_async.yaml | 126 +++++++-------- ...th_metadatas_with_scores_using_vector.yaml | 126 +++++++-------- ...adatas_with_scores_using_vector_async.yaml | 126 +++++++-------- .../vectorstores/test_upstash.py | 15 +- 28 files changed, 1346 insertions(+), 1811 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml index 866d8ecf39ba1..a9ed07a9c5a2c 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:16 GMT + - Sat, 27 Apr 2024 22:13:23 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:16 GMT + - Sat, 27 Apr 2024 22:13:23 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:16 GMT + - Sat, 27 Apr 2024 22:13:24 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:16 GMT + - Sat, 27 Apr 2024 22:13:24 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "c3d6c1fc-144a-4550-b0b6-0df30dca528e", "data": "penguin", "metadata": - {"topic": "bird", "text": "penguin"}}, {"id": "2843c257-5a00-41ca-baee-45e6616b2432", + body: '[{"id": "96c9fa52-9b0d-4604-917c-15f6b8529a95", "data": "penguin", "metadata": + {"topic": "bird", "text": "penguin"}}, {"id": "45910463-080a-419b-b5b1-e5698751e095", "data": "albatros", "metadata": {"topic": "bird", "text": "albatros"}}, {"id": - "e428e4e9-b6d1-4ee6-a240-3825c6a6d040", "data": "beethoven", "metadata": {"topic": - "composer", "text": "beethoven"}}, {"id": "0c5ae333-d55d-42d3-bf44-75df6519b227", + "5de2f1f3-99dd-4cc7-86dd-c017a84d532e", "data": "beethoven", "metadata": {"topic": + "composer", "text": "beethoven"}}, {"id": "476ecc40-b74f-40f4-90c0-2cbc4edc2a84", "data": "rachmaninoff", "metadata": {"topic": "composer", "text": "rachmaninoff"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/upsert-data response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:17 GMT + - Sat, 27 Apr 2024 22:13:24 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:17 GMT + - Sat, 27 Apr 2024 22:13:24 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:17 GMT + - Sat, 27 Apr 2024 22:13:25 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:18 GMT + - Sat, 27 Apr 2024 22:13:25 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": "", "data": "eagle"}' @@ -381,12 +365,11 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"c3d6c1fc-144a-4550-b0b6-0df30dca528e\",\n - \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n - \ }, {\n \"id\" : \"2843c257-5a00-41ca-baee-45e6616b2432\",\n \"score\" - : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"96c9fa52-9b0d-4604-917c-15f6b8529a95\",\n + \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n + \ }, {\n \"id\" : \"45910463-080a-419b-b5b1-e5698751e095\",\n \"score\" + : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -395,12 +378,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:18 GMT + - Sat, 27 Apr 2024 22:13:25 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": "", "data": "mozart"}' @@ -430,12 +412,11 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"e428e4e9-b6d1-4ee6-a240-3825c6a6d040\",\n - \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n - \ }, {\n \"id\" : \"0c5ae333-d55d-42d3-bf44-75df6519b227\",\n \"score\" - : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"5de2f1f3-99dd-4cc7-86dd-c017a84d532e\",\n + \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n + \ }, {\n \"id\" : \"476ecc40-b74f-40f4-90c0-2cbc4edc2a84\",\n \"score\" + : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -444,10 +425,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:18 GMT + - Sat, 27 Apr 2024 22:13:25 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml index 2c4855b1ff49c..a820df675297b 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embedding_index_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:18 GMT + - Sat, 27 Apr 2024 22:13:26 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:19 GMT + - Sat, 27 Apr 2024 22:13:26 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:19 GMT + - Sat, 27 Apr 2024 22:13:26 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:19 GMT + - Sat, 27 Apr 2024 22:13:26 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "c91b9d1b-4b1e-4223-bf88-5a6711bd9648", "data": "penguin", "metadata": - {"topic": "bird", "text": "penguin"}}, {"id": "baf22a55-e3b8-47f1-a43a-c5c6eb41d53d", + body: '[{"id": "c8c22d5e-0956-479e-ba89-cd3942b3ef6d", "data": "penguin", "metadata": + {"topic": "bird", "text": "penguin"}}, {"id": "ee439a03-e7cb-4162-ac5e-4321dc798a2c", "data": "albatros", "metadata": {"topic": "bird", "text": "albatros"}}, {"id": - "0c1f7416-625e-4d19-b18b-79e229fdca42", "data": "beethoven", "metadata": {"topic": - "composer", "text": "beethoven"}}, {"id": "ec613f2b-2bb8-430a-88bf-7ed374c201b1", + "9f9cc221-6956-4453-8ff0-db02c00ececb", "data": "beethoven", "metadata": {"topic": + "composer", "text": "beethoven"}}, {"id": "4e88c162-a98c-4e86-9a94-9ebbc558bdf1", "data": "rachmaninoff", "metadata": {"topic": "composer", "text": "rachmaninoff"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/upsert-data response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:19 GMT + - Sat, 27 Apr 2024 22:13:26 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:19 GMT + - Sat, 27 Apr 2024 22:13:27 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:20 GMT + - Sat, 27 Apr 2024 22:13:27 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 6470,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '158' + - '155' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:20 GMT + - Sat, 27 Apr 2024 22:13:28 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": "", "data": "eagle"}' @@ -381,12 +365,11 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"c91b9d1b-4b1e-4223-bf88-5a6711bd9648\",\n - \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n - \ }, {\n \"id\" : \"baf22a55-e3b8-47f1-a43a-c5c6eb41d53d\",\n \"score\" - : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"c8c22d5e-0956-479e-ba89-cd3942b3ef6d\",\n + \ \"score\" : 0.8220105,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"penguin\"}\n + \ }, {\n \"id\" : \"ee439a03-e7cb-4162-ac5e-4321dc798a2c\",\n \"score\" + : 0.7761154,\n \"metadata\" : {\"topic\":\"bird\",\"text\":\"albatros\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -395,12 +378,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:20 GMT + - Sat, 27 Apr 2024 22:13:28 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 2, "includeVectors": false, "includeMetadata": true, "filter": "", "data": "mozart"}' @@ -430,12 +412,11 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/query-data response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"0c1f7416-625e-4d19-b18b-79e229fdca42\",\n - \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n - \ }, {\n \"id\" : \"ec613f2b-2bb8-430a-88bf-7ed374c201b1\",\n \"score\" - : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"9f9cc221-6956-4453-8ff0-db02c00ececb\",\n + \ \"score\" : 0.88179696,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"beethoven\"}\n + \ }, {\n \"id\" : \"4e88c162-a98c-4e86-9a94-9ebbc558bdf1\",\n \"score\" + : 0.84151983,\n \"metadata\" : {\"topic\":\"composer\",\"text\":\"rachmaninoff\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -444,10 +425,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:21 GMT + - Sat, 27 Apr 2024 22:13:28 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml index 1b6918d19a408..f6259855bcf19 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_embeddings_configurations.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:15 GMT + - Sat, 27 Apr 2024 22:13:22 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:15 GMT + - Sat, 27 Apr 2024 22:13:23 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:15 GMT + - Sat, 27 Apr 2024 22:13:23 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,10 +158,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:16 GMT + - Sat, 27 Apr 2024 22:13:23 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml index 7d71e20044031..a2446fd1381ed 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_async_index.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:01 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:54 GMT + - Sat, 27 Apr 2024 22:13:01 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:54 GMT + - Sat, 27 Apr 2024 22:13:01 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:54 GMT + - Sat, 27 Apr 2024 22:13:01 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -197,10 +189,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -209,10 +200,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:54 GMT + - Sat, 27 Apr 2024 22:13:02 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml index f772c70c8f40a..1f5e71c877501 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:54 GMT + - Sat, 27 Apr 2024 22:13:02 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:55 GMT + - Sat, 27 Apr 2024 22:13:02 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:55 GMT + - Sat, 27 Apr 2024 22:13:02 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:55 GMT + - Sat, 27 Apr 2024 22:13:02 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -197,10 +189,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -209,10 +200,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:55 GMT + - Sat, 27 Apr 2024 22:13:03 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml index 7ce2a3d49727e..90e9043155362 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_credentials_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:55 GMT + - Sat, 27 Apr 2024 22:13:03 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:56 GMT + - Sat, 27 Apr 2024 22:13:03 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:56 GMT + - Sat, 27 Apr 2024 22:13:03 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:56 GMT + - Sat, 27 Apr 2024 22:13:03 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -197,10 +189,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -209,10 +200,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:56 GMT + - Sat, 27 Apr 2024 22:13:04 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml index 04603565b86ef..9c2d9a2c62e38 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_init_from_index.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:00 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:00 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:00 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:00 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -197,10 +189,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -209,10 +200,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:53 GMT + - Sat, 27 Apr 2024 22:13:01 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml index 6c6a36be651d6..b2752192d5162 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_mixed_metadata.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:06 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:06 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:06 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:07 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -201,8 +193,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -211,12 +202,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:07 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -243,24 +233,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" - : 2,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 2,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:59 GMT + - Sat, 27 Apr 2024 22:13:07 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -287,24 +275,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" - : 2,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 2,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:00 GMT + - Sat, 27 Apr 2024 22:13:07 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -331,24 +317,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 2,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:08 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 4, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -378,10 +362,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"0\",\n \"score\" : 1.0,\n - \ \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" : \"1\",\n \"score\" - : 0.97434163,\n \"metadata\" : {\"baz\":1,\"text\":\"bar\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"0\",\n \"score\" : 1.0,\n \"metadata\" + : {\"text\":\"foo\"}\n }, {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"metadata\" : {\"baz\":1,\"text\":\"bar\"}\n } ]\n}" headers: Connection: - keep-alive @@ -390,10 +373,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:08 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml index c593713ee6258..8d22dc79c6fb6 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_add_documents_no_metadata.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:56 GMT + - Sat, 27 Apr 2024 22:13:04 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:57 GMT + - Sat, 27 Apr 2024 22:13:04 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:57 GMT + - Sat, 27 Apr 2024 22:13:04 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,14 +158,13 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:57 GMT + - Sat, 27 Apr 2024 22:13:04 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "00a18513-7630-4a38-89be-dbea501b2d2d", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "f257357d-afc3-4b8b-b11e-058bc2911cb3", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}]' headers: User-Agent: @@ -200,8 +192,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -210,12 +201,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:57 GMT + - Sat, 27 Apr 2024 22:13:05 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -242,24 +232,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" - : 1,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 1,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:57 GMT + - Sat, 27 Apr 2024 22:13:05 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -286,24 +274,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" - : 1,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 1,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:58 GMT + - Sat, 27 Apr 2024 22:13:05 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -330,24 +316,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 1,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:58 GMT + - Sat, 27 Apr 2024 22:13:06 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 4, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -377,9 +361,8 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"00a18513-7630-4a38-89be-dbea501b2d2d\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"f257357d-afc3-4b8b-b11e-058bc2911cb3\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" headers: Connection: - keep-alive @@ -388,10 +371,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:58 GMT + - Sat, 27 Apr 2024 22:13:06 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml index bb8fbe25850c0..548d604e37a3c 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:18 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:18 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:18 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:18 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:19 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:11 GMT + - Sat, 27 Apr 2024 22:13:19 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:12 GMT + - Sat, 27 Apr 2024 22:13:19 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:12 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,12 +365,11 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" - : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -395,10 +378,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml index cfa31240c2faf..7a9827b166c64 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_max_marginal_relevance_search_with_metadata_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:20 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:13 GMT + - Sat, 27 Apr 2024 22:13:21 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:14 GMT + - Sat, 27 Apr 2024 22:13:21 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:14 GMT + - Sat, 27 Apr 2024 22:13:21 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:15 GMT + - Sat, 27 Apr 2024 22:13:22 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,12 +365,11 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" - : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 2.0 ],\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -395,10 +378,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:15 GMT + - Sat, 27 Apr 2024 22:13:22 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml index 09b2b3e0b0cbd..ef01665d48e8d 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:43 GMT + - Sat, 27 Apr 2024 22:12:50 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:43 GMT + - Sat, 27 Apr 2024 22:12:51 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:43 GMT + - Sat, 27 Apr 2024 22:12:51 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:43 GMT + - Sat, 27 Apr 2024 22:12:51 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "2596d017-3ece-4f78-8298-317f42845a95", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "78c5c468-6b24-4fc1-b85e-aa3da1442187", + body: '[{"id": "472e5e66-cff2-486a-b7cb-7d8303d876e4", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "fe3c1367-3e51-4aa4-a8b6-63a88f6a01c5", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "b5e48d09-e77a-4a37-b5e2-3c7b2f1d3b58", "vector": [1.0, 1.0, + "bar"}}, {"id": "2adfb8da-3149-4f63-9451-130bf8dc7c63", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:44 GMT + - Sat, 27 Apr 2024 22:12:51 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:44 GMT + - Sat, 27 Apr 2024 22:12:51 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:44 GMT + - Sat, 27 Apr 2024 22:12:52 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:45 GMT + - Sat, 27 Apr 2024 22:12:52 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,15 +364,14 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"2596d017-3ece-4f78-8298-317f42845a95\",\n - \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" - : \"78c5c468-6b24-4fc1-b85e-aa3da1442187\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"text\":\"bar\"}\n }, {\n \"id\" : \"b5e48d09-e77a-4a37-b5e2-3c7b2f1d3b58\",\n - \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"472e5e66-cff2-486a-b7cb-7d8303d876e4\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"fe3c1367-3e51-4aa4-a8b6-63a88f6a01c5\",\n \"score\" : 0.97434163,\n \"vector\" + : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" : + {\"text\":\"bar\"}\n }, {\n \"id\" : \"2adfb8da-3149-4f63-9451-130bf8dc7c63\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -397,10 +380,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:45 GMT + - Sat, 27 Apr 2024 22:12:52 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml index db2e172672ccc..aa42576ea6395 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:45 GMT + - Sat, 27 Apr 2024 22:12:53 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:45 GMT + - Sat, 27 Apr 2024 22:12:53 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:46 GMT + - Sat, 27 Apr 2024 22:12:53 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:46 GMT + - Sat, 27 Apr 2024 22:12:53 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "a9af95ed-b0f7-4ea9-a7bf-bc1224cc2504", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "5e1802fb-31e3-4424-840f-25da228f7a07", + body: '[{"id": "4b8f3bb6-6bad-4306-b8ca-3e556036e3e6", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "2cbb9a21-7516-4003-94d1-1e5e3465f5aa", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "ef9e3286-0d28-42bc-aaed-faeed7a1c9cd", "vector": [1.0, 1.0, + "bar"}}, {"id": "c00f79c0-e4ef-4e2f-bed4-f2c39e0a69de", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:46 GMT + - Sat, 27 Apr 2024 22:12:53 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:46 GMT + - Sat, 27 Apr 2024 22:12:54 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:47 GMT + - Sat, 27 Apr 2024 22:12:54 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:47 GMT + - Sat, 27 Apr 2024 22:12:55 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,15 +364,14 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"a9af95ed-b0f7-4ea9-a7bf-bc1224cc2504\",\n - \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" - : \"5e1802fb-31e3-4424-840f-25da228f7a07\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"text\":\"bar\"}\n }, {\n \"id\" : \"ef9e3286-0d28-42bc-aaed-faeed7a1c9cd\",\n - \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"4b8f3bb6-6bad-4306-b8ca-3e556036e3e6\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"2cbb9a21-7516-4003-94d1-1e5e3465f5aa\",\n \"score\" : 0.97434163,\n \"vector\" + : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" : + {\"text\":\"bar\"}\n }, {\n \"id\" : \"c00f79c0-e4ef-4e2f-bed4-f2c39e0a69de\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -397,10 +380,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:47 GMT + - Sat, 27 Apr 2024 22:12:55 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml index ab26a04143d2a..5780a153401b9 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:48 GMT + - Sat, 27 Apr 2024 22:12:55 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:48 GMT + - Sat, 27 Apr 2024 22:12:55 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:48 GMT + - Sat, 27 Apr 2024 22:12:56 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:48 GMT + - Sat, 27 Apr 2024 22:12:56 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "a087b72e-906f-4724-a867-4af800e67052", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "f561d2fb-113f-44de-8f97-133984e195da", + body: '[{"id": "123c5bf9-c966-4114-a9ee-9d82e91ede9b", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "875e5411-d454-49c0-90b9-6be3bcee8857", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "0bb4529a-9431-49d8-ba5b-4af6813e4435", "vector": [1.0, 1.0, + "bar"}}, {"id": "a192b77f-0975-4c8c-9bd1-1cbd0458a3b8", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:49 GMT + - Sat, 27 Apr 2024 22:12:56 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:49 GMT + - Sat, 27 Apr 2024 22:12:56 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:49 GMT + - Sat, 27 Apr 2024 22:12:57 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:50 GMT + - Sat, 27 Apr 2024 22:12:57 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,15 +364,14 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"a087b72e-906f-4724-a867-4af800e67052\",\n - \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" - : \"f561d2fb-113f-44de-8f97-133984e195da\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"text\":\"bar\"}\n }, {\n \"id\" : \"0bb4529a-9431-49d8-ba5b-4af6813e4435\",\n - \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"123c5bf9-c966-4114-a9ee-9d82e91ede9b\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"875e5411-d454-49c0-90b9-6be3bcee8857\",\n \"score\" : 0.97434163,\n \"vector\" + : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" : + {\"text\":\"bar\"}\n }, {\n \"id\" : \"a192b77f-0975-4c8c-9bd1-1cbd0458a3b8\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -397,10 +380,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:50 GMT + - Sat, 27 Apr 2024 22:12:57 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml index b7b43bd43a273..18e5bef5dabf1 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_mmr_by_vector_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:50 GMT + - Sat, 27 Apr 2024 22:12:57 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:50 GMT + - Sat, 27 Apr 2024 22:12:58 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:50 GMT + - Sat, 27 Apr 2024 22:12:58 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:51 GMT + - Sat, 27 Apr 2024 22:12:58 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "cda72878-0b62-4790-a565-e5b3ec2f62c4", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "7246c7a9-9f83-4867-a0a7-b8e68358afc4", + body: '[{"id": "032c7822-ac85-4aa3-ad58-9c8f86d3a36e", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "6e6e5ef2-f5d7-40ca-925b-2a78a451b872", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "59ef5dfa-b434-4bec-892e-9f18ac4bed9f", "vector": [1.0, 1.0, + "bar"}}, {"id": "2f06ebc7-8d72-4861-909e-1e4bf26a1edc", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:51 GMT + - Sat, 27 Apr 2024 22:12:58 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:51 GMT + - Sat, 27 Apr 2024 22:12:58 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:51 GMT + - Sat, 27 Apr 2024 22:12:59 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:52 GMT + - Sat, 27 Apr 2024 22:12:59 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 20, "includeVectors": true, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,15 +364,14 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"cda72878-0b62-4790-a565-e5b3ec2f62c4\",\n - \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" - : \"7246c7a9-9f83-4867-a0a7-b8e68358afc4\",\n \"score\" : 0.97434163,\n - \ \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" - : {\"text\":\"bar\"}\n }, {\n \"id\" : \"59ef5dfa-b434-4bec-892e-9f18ac4bed9f\",\n - \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"032c7822-ac85-4aa3-ad58-9c8f86d3a36e\",\n + \ \"score\" : 1.0,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 0.0 ],\n \"metadata\" : {\"text\":\"foo\"}\n }, {\n \"id\" + : \"6e6e5ef2-f5d7-40ca-925b-2a78a451b872\",\n \"score\" : 0.97434163,\n \"vector\" + : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ],\n \"metadata\" : + {\"text\":\"bar\"}\n }, {\n \"id\" : \"2f06ebc7-8d72-4861-909e-1e4bf26a1edc\",\n + \ \"score\" : 0.91602516,\n \"vector\" : [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 2.0 ],\n \"metadata\" : {\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -397,10 +380,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:52 GMT + - Sat, 27 Apr 2024 22:13:00 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml index cacf31e686029..f7c5a36fcc9a1 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:06 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:06 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:06 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:06 GMT + - Sat, 27 Apr 2024 22:13:14 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:07 GMT + - Sat, 27 Apr 2024 22:13:14 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:07 GMT + - Sat, 27 Apr 2024 22:13:14 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:07 GMT + - Sat, 27 Apr 2024 22:13:14 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:15 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]}' @@ -381,11 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n - \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n - \ \"score\" : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -394,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:15 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml index e80434fc2e120..3527644cb2f23 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_by_vector_with_metadata_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:15 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:16 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:16 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:08 GMT + - Sat, 27 Apr 2024 22:13:16 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:09 GMT + - Sat, 27 Apr 2024 22:13:16 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:09 GMT + - Sat, 27 Apr 2024 22:13:16 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:09 GMT + - Sat, 27 Apr 2024 22:13:17 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:10 GMT + - Sat, 27 Apr 2024 22:13:17 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]}' @@ -381,11 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n - \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n - \ \"score\" : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 1.0,\n \"metadata\" + : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n \"score\" + : 0.98238194,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n } ]\n}" headers: Connection: - keep-alive @@ -394,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:10 GMT + - Sat, 27 Apr 2024 22:13:18 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml index 176979c3c8a01..6075b1c2828d8 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:08 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:09 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:09 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:01 GMT + - Sat, 27 Apr 2024 22:13:09 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:02 GMT + - Sat, 27 Apr 2024 22:13:09 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:02 GMT + - Sat, 27 Apr 2024 22:13:09 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:02 GMT + - Sat, 27 Apr 2024 22:13:10 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:03 GMT + - Sat, 27 Apr 2024 22:13:10 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,11 +365,10 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n - \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n - \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -394,12 +377,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:03 GMT + - Sat, 27 Apr 2024 22:13:10 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -429,9 +411,8 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n - \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n + \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" headers: Connection: - keep-alive @@ -440,10 +421,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:03 GMT + - Sat, 27 Apr 2024 22:13:10 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml index b80fb883425d9..af1a672fdc471 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_similarity_search_with_metadata_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:03 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:03 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:04 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,12 +158,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:04 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '[{"id": "0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:04 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:04 GMT + - Sat, 27 Apr 2024 22:13:11 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 4,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 4,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:05 GMT + - Sat, 27 Apr 2024 22:13:12 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 4,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:05 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,11 +365,10 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n - \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n - \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"1\",\n \"score\" : 0.97434163,\n + \ \"metadata\" : {\"waldo\":1,\"text\":\"bar\"}\n }, {\n \"id\" : \"3\",\n + \ \"score\" : 0.91602516,\n \"metadata\" : {\"waldo\":1,\"text\":\"baz\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -394,12 +377,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:05 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 5, "includeVectors": false, "includeMetadata": true, "filter": "waldo = 2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -429,9 +411,8 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n - \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"4\",\n \"score\" : 0.8535534,\n + \ \"metadata\" : {\"waldo\":2,\"text\":\"fred\"}\n } ]\n}" headers: Connection: - keep-alive @@ -440,10 +421,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:45:06 GMT + - Sat, 27 Apr 2024 22:13:13 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml index 7a64df116cea7..78a3d577edb93 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:24 GMT + - Sat, 27 Apr 2024 22:12:31 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:24 GMT + - Sat, 27 Apr 2024 22:12:32 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:24 GMT + - Sat, 27 Apr 2024 22:12:32 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:24 GMT + - Sat, 27 Apr 2024 22:12:32 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "03f31e48-b455-4d3f-9b75-80cd8fa5be4b", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "cc432a24-a3c7-47e3-a806-399c7dde2a92", + body: '[{"id": "df2e3e00-2f2b-42eb-bcce-f3f075c30dd4", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "0c26d6cf-e398-4792-b6b1-02ba271d45b5", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "08a56f3c-c711-4329-95cd-8516e2f05df3", "vector": [1.0, 1.0, + "bar"}}, {"id": "c5daa486-516b-4f7c-a426-0eef29a79f4c", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:25 GMT + - Sat, 27 Apr 2024 22:12:32 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:25 GMT + - Sat, 27 Apr 2024 22:12:32 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:25 GMT + - Sat, 27 Apr 2024 22:12:33 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:26 GMT + - Sat, 27 Apr 2024 22:12:33 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,9 +364,8 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"03f31e48-b455-4d3f-9b75-80cd8fa5be4b\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"df2e3e00-2f2b-42eb-bcce-f3f075c30dd4\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" headers: Connection: - keep-alive @@ -391,10 +374,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:26 GMT + - Sat, 27 Apr 2024 22:12:33 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml index 4538ff52dc27c..13b7e9d9c7956 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_simple_insert_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:26 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:27 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:27 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,17 +158,16 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:27 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "e087e36e-79c3-4a54-bd2a-97626f9a6672", "vector": [1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "864b4e8d-7b2b-4e3b-8295-9bc3d8a3e84b", + body: '[{"id": "4801d1a3-4849-438a-a889-c15fc5284bbb", "vector": [1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"text": "foo"}}, {"id": "2f9748c5-054f-4b16-97c5-575cd7963dfc", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"text": - "bar"}}, {"id": "ea52dce9-09f5-44a3-aa2a-17c6074f0a93", "vector": [1.0, 1.0, + "bar"}}, {"id": "2acbdc43-383b-44d8-983f-cd4ac795ced8", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"text": "baz"}}]' headers: User-Agent: @@ -203,8 +195,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -213,12 +204,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:27 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -245,24 +235,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:27 GMT + - Sat, 27 Apr 2024 22:12:34 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -289,24 +277,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:28 GMT + - Sat, 27 Apr 2024 22:12:35 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -333,24 +319,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:28 GMT + - Sat, 27 Apr 2024 22:12:36 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -380,9 +364,8 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"e087e36e-79c3-4a54-bd2a-97626f9a6672\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"4801d1a3-4849-438a-a889-c15fc5284bbb\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"text\":\"foo\"}\n } ]\n}" headers: Connection: - keep-alive @@ -391,10 +374,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:28 GMT + - Sat, 27 Apr 2024 22:12:36 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml index 9d50448bf0725..9025188d673bd 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:36 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:36 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:37 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:37 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "dd2765fb-75dd-4cab-bf39-e0f2f2c7efd8", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "f814b1de-8d08-4355-aeed-367f95628449", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "4416d38f-3bd5-496c-a15a-ccfaed29e26f", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "9501ae4e-5068-48a9-b610-13c66d7e0a6c", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "608ded88-6e6d-45bb-b433-7f1f65d5e500", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "f02e41ba-cd46-4d42-8c37-336b5ec3b2a6", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:37 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:29 GMT + - Sat, 27 Apr 2024 22:12:37 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:30 GMT + - Sat, 27 Apr 2024 22:12:38 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:38 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"dd2765fb-75dd-4cab-bf39-e0f2f2c7efd8\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"f814b1de-8d08-4355-aeed-367f95628449\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:38 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml index 4a01e6cec10ad..3d84eb2409e2f 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:31 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "dc7bf301-074f-482d-90ca-e5db2aaf7856", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "a428767d-458a-40ae-8062-474d4f52ef9f", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "c2aa384e-7ab9-44c8-a67a-19d2f3e005ec", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "809f1c20-4844-4be7-abde-6257d53a2568", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "ba09467b-6d64-48a4-a7eb-a7f1d18d29a2", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "3b3df2a7-62d5-4fb8-a448-4687ae9a2517", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:32 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:32 GMT + - Sat, 27 Apr 2024 22:12:39 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:32 GMT + - Sat, 27 Apr 2024 22:12:40 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:33 GMT + - Sat, 27 Apr 2024 22:12:40 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"dc7bf301-074f-482d-90ca-e5db2aaf7856\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"a428767d-458a-40ae-8062-474d4f52ef9f\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:33 GMT + - Sat, 27 Apr 2024 22:12:41 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml index 9aa30e1f02f14..1271c44fb92e3 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:33 GMT + - Sat, 27 Apr 2024 22:12:41 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:34 GMT + - Sat, 27 Apr 2024 22:12:41 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:34 GMT + - Sat, 27 Apr 2024 22:12:41 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:34 GMT + - Sat, 27 Apr 2024 22:12:41 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "e8719d31-0b3a-4882-81ae-74ea7d362054", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "2b5839f2-695d-403c-9e97-9948d6d424b6", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "7ec8a1b1-a120-4cd1-88fa-c74510da1f57", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "2f91018e-9103-4364-b5b3-13f963e699fa", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "0d87b9db-6081-45f6-a97f-8874c8980fee", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "cfd09a2e-5c01-4ae7-b0eb-cc5fa1250b6f", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:34 GMT + - Sat, 27 Apr 2024 22:12:42 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:34 GMT + - Sat, 27 Apr 2024 22:12:42 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:35 GMT + - Sat, 27 Apr 2024 22:12:42 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:35 GMT + - Sat, 27 Apr 2024 22:12:43 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"e8719d31-0b3a-4882-81ae-74ea7d362054\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"2b5839f2-695d-403c-9e97-9948d6d424b6\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:35 GMT + - Sat, 27 Apr 2024 22:12:43 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml index 3f0b4ed9a6933..8cb4431af9be6 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:43 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:43 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:44 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:44 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "ecbee7c1-f349-4647-8058-8d4a3c21f3d6", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "6eff2fec-f708-42b9-b316-47672ccf0d1c", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "e0a194f3-92fd-40ba-a5fd-892f075d6e11", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "23724c45-05f2-433a-9ad6-a26ac2a78fe0", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "f91cf846-2f1a-4587-9713-b25815adcdc5", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "8bfa3095-4cc8-4e7f-8072-1dde52f09969", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:44 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:36 GMT + - Sat, 27 Apr 2024 22:12:44 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:37 GMT + - Sat, 27 Apr 2024 22:12:45 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:38 GMT + - Sat, 27 Apr 2024 22:12:45 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"ecbee7c1-f349-4647-8058-8d4a3c21f3d6\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"6eff2fec-f708-42b9-b316-47672ccf0d1c\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:38 GMT + - Sat, 27 Apr 2024 22:12:45 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml index 5542bec8c9f20..1621de1f32359 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:38 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:38 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:38 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:39 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "cad5b766-d164-4bd8-856d-1d9558483ca1", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "5121e95d-276d-44fe-9287-a092ae09b6ea", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "ff046a51-4b15-4c11-a084-013c5eebde7c", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "4fca424a-d7e8-4ebe-a298-0cf772a461e1", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "2cdb2f17-2e5f-4dc8-9d14-cd8642be4b69", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "e102bc06-b921-4e93-921e-c63e03953126", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:39 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:39 GMT + - Sat, 27 Apr 2024 22:12:46 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:39 GMT + - Sat, 27 Apr 2024 22:12:47 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:40 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"cad5b766-d164-4bd8-856d-1d9558483ca1\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"5121e95d-276d-44fe-9287-a092ae09b6ea\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:40 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml index d03f46bdb820f..36e3d934e9d90 100644 --- a/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml +++ b/libs/community/tests/integration_tests/vectorstores/cassettes/test_upstash/test_upstash_with_metadatas_with_scores_using_vector_async.yaml @@ -25,8 +25,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -35,12 +34,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:40 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -67,8 +65,7 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/reset response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -77,12 +74,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:41 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -109,10 +105,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -121,12 +116,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:41 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -153,10 +147,9 @@ interactions: method: POST uri: https://thankful-dane-25695-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 0,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 0,\n \"dimension\" : 384,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive @@ -165,18 +158,17 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:41 GMT + - Sat, 27 Apr 2024 22:12:48 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: - body: '[{"id": "3c3699b1-fded-4d20-add3-aeed630f3894", "vector": [1.0, 1.0, 1.0, + body: '[{"id": "deb53135-eb87-4d69-8e59-7243bce077dc", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0], "metadata": {"page": "0", "text": "foo"}}, - {"id": "5324945d-39c4-4a40-a4cf-80b28a0e993e", "vector": [1.0, 1.0, 1.0, 1.0, + {"id": "6cc5fbe9-3982-4911-98b8-ff9490c0cf42", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "metadata": {"page": "1", "text": "bar"}}, {"id": - "e425444c-d555-4b9f-877d-e04914551342", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, + "b1826c53-2a31-4853-840d-91f038398f8d", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0], "metadata": {"page": "2", "text": "baz"}}]' headers: User-Agent: @@ -204,8 +196,7 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/upsert response: - body: - string: "{\n \"result\" : \"Success\"\n}" + content: "{\n \"result\" : \"Success\"\n}" headers: Connection: - keep-alive @@ -214,12 +205,11 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:41 GMT + - Sat, 27 Apr 2024 22:12:49 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -246,24 +236,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:41 GMT + - Sat, 27 Apr 2024 22:12:49 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -290,24 +278,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 3,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 3,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:42 GMT + - Sat, 27 Apr 2024 22:12:49 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '' headers: @@ -334,24 +320,22 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/info response: - body: - string: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" - : 0,\n \"indexSize\" : 0,\n \"dimension\" : 10,\n \"similarityFunction\" - : \"COSINE\"\n }\n}" + content: "{\n \"result\" : {\n \"vectorCount\" : 3,\n \"pendingVectorCount\" + : 0,\n \"indexSize\" : 295,\n \"dimension\" : 10,\n \"similarityFunction\" + : \"COSINE\"\n }\n}" headers: Connection: - keep-alive Content-Length: - - '154' + - '156' Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:42 GMT + - Sat, 27 Apr 2024 22:12:50 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 - request: body: '{"topK": 1, "includeVectors": false, "includeMetadata": true, "filter": "", "vector": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0]}' @@ -381,10 +365,9 @@ interactions: method: POST uri: https://fond-mutt-96644-eu1-vector.upstash.io/query response: - body: - string: "{\n \"result\" : [ {\n \"id\" : \"3c3699b1-fded-4d20-add3-aeed630f3894\",\n - \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n - \ } ]\n}" + content: "{\n \"result\" : [ {\n \"id\" : \"deb53135-eb87-4d69-8e59-7243bce077dc\",\n + \ \"score\" : 1.0,\n \"metadata\" : {\"page\":\"0\",\"text\":\"foo\"}\n + \ } ]\n}" headers: Connection: - keep-alive @@ -393,10 +376,9 @@ interactions: Content-Type: - application/json Date: - - Sat, 27 Apr 2024 21:44:43 GMT + - Sat, 27 Apr 2024 22:12:50 GMT Strict-Transport-Security: - max-age=31536000; includeSubDomains - status: - code: 200 - message: OK + http_version: HTTP/1.1 + status_code: 200 version: 1 diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index 2c2586825fbc3..ea91c6996ab77 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -2,25 +2,20 @@ import os from time import sleep -from typing import TYPE_CHECKING, List, Tuple, Union +from typing import List, Tuple, Union # to fix the following error in test with vcr and asyncio # # RuntimeError: asyncio.run() cannot be called from a running event loop -import nest_asyncio import pytest from langchain_core.documents import Document +from upstash_vector import AsyncIndex, Index from langchain_community.vectorstores.upstash import UpstashVectorStore from tests.integration_tests.vectorstores.fake_embeddings import ( FakeEmbeddings, ) -nest_asyncio.apply() - -if TYPE_CHECKING: - from upstash_vector import Index - @pytest.fixture(scope="module") def vcr_cassette_dir() -> str: @@ -30,8 +25,6 @@ def vcr_cassette_dir() -> str: @pytest.fixture(scope="function", autouse=True) def fixture() -> None: - from upstash_vector import Index - index = Index.from_env() embedding_index = Index( url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], @@ -235,8 +228,6 @@ async def test_upstash_mmr_by_vector_async() -> None: @pytest.mark.vcr() def test_init_from_index() -> None: - from upstash_vector import Index - index = Index.from_env() store = UpstashVectorStore(index=index) @@ -247,8 +238,6 @@ def test_init_from_index() -> None: @pytest.mark.vcr() @pytest.mark.asyncio async def test_init_from_async_index() -> None: - from upstash_vector import AsyncIndex - index = AsyncIndex.from_env() store = UpstashVectorStore(async_index=index) From 40d035c9a88b581c4904b6779c30718e83f0becc Mon Sep 17 00:00:00 2001 From: CahidArda Date: Sun, 28 Apr 2024 02:10:36 +0300 Subject: [PATCH 41/41] move upstash_vector import into functions --- .../vectorstores/test_upstash.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_upstash.py b/libs/community/tests/integration_tests/vectorstores/test_upstash.py index ea91c6996ab77..7da52dd8b7de1 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_upstash.py +++ b/libs/community/tests/integration_tests/vectorstores/test_upstash.py @@ -2,14 +2,13 @@ import os from time import sleep -from typing import List, Tuple, Union +from typing import List, Tuple # to fix the following error in test with vcr and asyncio # # RuntimeError: asyncio.run() cannot be called from a running event loop import pytest from langchain_core.documents import Document -from upstash_vector import AsyncIndex, Index from langchain_community.vectorstores.upstash import UpstashVectorStore from tests.integration_tests.vectorstores.fake_embeddings import ( @@ -25,20 +24,20 @@ def vcr_cassette_dir() -> str: @pytest.fixture(scope="function", autouse=True) def fixture() -> None: - index = Index.from_env() - embedding_index = Index( - url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], - token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], + store = UpstashVectorStore() + embedding_store = UpstashVectorStore( + index_url=os.environ["UPSTASH_VECTOR_URL_EMBEDDING"], + index_token=os.environ["UPSTASH_VECTOR_TOKEN_EMBEDDING"], ) - index.reset() - embedding_index.reset() + store.delete(delete_all=True) + embedding_store.delete(delete_all=True) - wait_for_indexing(index) - wait_for_indexing(embedding_index) + wait_for_indexing(store) + wait_for_indexing(embedding_store) -def wait_for_indexing(store: Union[Index, UpstashVectorStore]) -> None: +def wait_for_indexing(store: UpstashVectorStore) -> None: while store.info().pending_vector_count != 0: # Wait for indexing to complete sleep(0.5) @@ -228,6 +227,8 @@ async def test_upstash_mmr_by_vector_async() -> None: @pytest.mark.vcr() def test_init_from_index() -> None: + from upstash_vector import Index + index = Index.from_env() store = UpstashVectorStore(index=index) @@ -238,6 +239,8 @@ def test_init_from_index() -> None: @pytest.mark.vcr() @pytest.mark.asyncio async def test_init_from_async_index() -> None: + from upstash_vector import AsyncIndex + index = AsyncIndex.from_env() store = UpstashVectorStore(async_index=index)