From 52383c7ffe7125a65c6ad1cbcdd4d328d6255726 Mon Sep 17 00:00:00 2001
From: Ravi Theja <ravi03071991@gmail.com>
Date: Mon, 26 Feb 2024 22:13:53 +0530
Subject: [PATCH] Update opensearch vectorstore to PydanticVectorStore class
 (#11400)

---
 .../llama_index/vector_stores/opensearch/base.py           | 7 +++++--
 .../tests/test_vector_stores_opensearch.py                 | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py
index 7644617b3d..508ef45752 100644
--- a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py
+++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py
@@ -2,11 +2,12 @@
 import json
 import uuid
 from typing import Any, Dict, Iterable, List, Optional, Union, cast
+from llama_index.core.bridge.pydantic import PrivateAttr
 
 from llama_index.core.schema import BaseNode, MetadataMode, TextNode
 from llama_index.core.vector_stores.types import (
     MetadataFilters,
-    VectorStore,
+    BasePydanticVectorStore,
     VectorStoreQuery,
     VectorStoreQueryMode,
     VectorStoreQueryResult,
@@ -419,7 +420,7 @@ class OpensearchVectorClient:
         return VectorStoreQueryResult(nodes=nodes, ids=ids, similarities=scores)
 
 
-class OpensearchVectorStore(VectorStore):
+class OpensearchVectorStore(BasePydanticVectorStore):
     """Elasticsearch/Opensearch vector store.
 
     Args:
@@ -428,12 +429,14 @@ class OpensearchVectorStore(VectorStore):
     """
 
     stores_text: bool = True
+    _client: OpensearchVectorClient = PrivateAttr(default=None)
 
     def __init__(
         self,
         client: OpensearchVectorClient,
     ) -> None:
         """Initialize params."""
+        super().__init__()
         self._client = client
 
     @property
diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/tests/test_vector_stores_opensearch.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/tests/test_vector_stores_opensearch.py
index af29f16d57..a63124b389 100644
--- a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/tests/test_vector_stores_opensearch.py
+++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/tests/test_vector_stores_opensearch.py
@@ -1,7 +1,7 @@
-from llama_index.core.vector_stores.types import VectorStore
+from llama_index.core.vector_stores.types import BasePydanticVectorStore
 from llama_index.vector_stores.opensearch import OpensearchVectorStore
 
 
 def test_class():
     names_of_base_classes = [b.__name__ for b in OpensearchVectorStore.__mro__]
-    assert VectorStore.__name__ in names_of_base_classes
+    assert BasePydanticVectorStore.__name__ in names_of_base_classes
-- 
GitLab