Copilot commented on code in PR #304:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/304#discussion_r2465615825


##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def remove(self, props: Union[Set[Any], List[Any]]) -> int:
+        """
+        Remove vectors based on their associated properties.
+
+        Args:
+            props (Union[Set[Any], List[Any]]): Properties of vectors to 
remove.
+
+        Returns:
+            int: Number of vectors removed.
+        """
+
+    @abstractmethod
+    def search(
+        self, query_vector: List[float], top_k: int, dis_threshold: float = 0.9
+    ) -> List[Any]:
+        """
+        Search for the top_k most similar vectors to the query vector.
+
+        Args:
+            query_vector (List[float]): The vector to query against the index.
+            top_k (int): Number of top results to return.
+            dis_threshold (float): Distance threshold below which results are 
considered relevant.
+
+        Returns:
+            List[Any]: List of properties of the matched vectors.
+        """
+
+    @abstractmethod
+    def save_index_by_name(self, *name: str):
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def get_vector_index_info(
+        self,
+    ) -> Dict:
+        """
+        #TODO: finish comment

Review Comment:
   The docstring is incomplete. Consider documenting what 
`get_vector_index_info` returns and its purpose.
   ```suggestion
           Retrieve information and metadata about the vector index.
   
           Returns:
               Dict: A dictionary containing details about the vector index, 
such as its configuration,
               statistics, and other relevant metadata.
   ```



##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def remove(self, props: Union[Set[Any], List[Any]]) -> int:
+        """
+        Remove vectors based on their associated properties.
+
+        Args:
+            props (Union[Set[Any], List[Any]]): Properties of vectors to 
remove.
+
+        Returns:
+            int: Number of vectors removed.
+        """
+
+    @abstractmethod
+    def search(
+        self, query_vector: List[float], top_k: int, dis_threshold: float = 0.9
+    ) -> List[Any]:
+        """
+        Search for the top_k most similar vectors to the query vector.
+
+        Args:
+            query_vector (List[float]): The vector to query against the index.
+            top_k (int): Number of top results to return.
+            dis_threshold (float): Distance threshold below which results are 
considered relevant.
+
+        Returns:
+            List[Any]: List of properties of the matched vectors.
+        """
+
+    @abstractmethod
+    def save_index_by_name(self, *name: str):
+        """
+        #TODO: finish comment

Review Comment:
   The docstring is incomplete. Consider documenting what `save_index_by_name` 
does and its parameters.
   ```suggestion
           Save the vector index to persistent storage, identified by the given 
name(s).
   
           Args:
               name (str): One or more names identifying the index to save.
   ```



##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def remove(self, props: Union[Set[Any], List[Any]]) -> int:
+        """
+        Remove vectors based on their associated properties.
+
+        Args:
+            props (Union[Set[Any], List[Any]]): Properties of vectors to 
remove.
+
+        Returns:
+            int: Number of vectors removed.
+        """
+
+    @abstractmethod
+    def search(
+        self, query_vector: List[float], top_k: int, dis_threshold: float = 0.9
+    ) -> List[Any]:
+        """
+        Search for the top_k most similar vectors to the query vector.
+
+        Args:
+            query_vector (List[float]): The vector to query against the index.
+            top_k (int): Number of top results to return.
+            dis_threshold (float): Distance threshold below which results are 
considered relevant.
+
+        Returns:
+            List[Any]: List of properties of the matched vectors.
+        """
+
+    @abstractmethod
+    def save_index_by_name(self, *name: str):
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def get_vector_index_info(
+        self,
+    ) -> Dict:
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def from_name(embed_dim: int, *name: str) -> "VectorStoreBase":
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def exist(*name: str) -> bool:
+        """
+        #TODO: finish comment

Review Comment:
   The docstring is incomplete. Consider documenting what `exist` checks and 
its parameters.
   ```suggestion
           Check whether a vector index with the given name(s) exists.
   
           Args:
               *name (str): One or more names identifying the vector index to 
check.
   
           Returns:
               bool: True if the vector index exists, False otherwise.
   ```



##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def remove(self, props: Union[Set[Any], List[Any]]) -> int:
+        """
+        Remove vectors based on their associated properties.
+
+        Args:
+            props (Union[Set[Any], List[Any]]): Properties of vectors to 
remove.
+
+        Returns:
+            int: Number of vectors removed.
+        """
+
+    @abstractmethod
+    def search(
+        self, query_vector: List[float], top_k: int, dis_threshold: float = 0.9
+    ) -> List[Any]:
+        """
+        Search for the top_k most similar vectors to the query vector.
+
+        Args:
+            query_vector (List[float]): The vector to query against the index.
+            top_k (int): Number of top results to return.
+            dis_threshold (float): Distance threshold below which results are 
considered relevant.
+
+        Returns:
+            List[Any]: List of properties of the matched vectors.
+        """
+
+    @abstractmethod
+    def save_index_by_name(self, *name: str):
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def get_vector_index_info(
+        self,
+    ) -> Dict:
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def from_name(embed_dim: int, *name: str) -> "VectorStoreBase":
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def exist(*name: str) -> bool:
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def clean(*name: str) -> bool:
+        """
+        #TODO: finish comment

Review Comment:
   The return type annotation is `bool` but the docstring is incomplete. 
Clarify what the method returns and document its parameters.
   ```suggestion
           Remove or clean up the vector index identified by the given name(s).
   
           Args:
               *name (str): One or more names identifying the vector index(es) 
to clean.
   
           Returns:
               bool: True if the cleanup was successful, False otherwise.
   ```



##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def remove(self, props: Union[Set[Any], List[Any]]) -> int:
+        """
+        Remove vectors based on their associated properties.
+
+        Args:
+            props (Union[Set[Any], List[Any]]): Properties of vectors to 
remove.
+
+        Returns:
+            int: Number of vectors removed.
+        """
+
+    @abstractmethod
+    def search(
+        self, query_vector: List[float], top_k: int, dis_threshold: float = 0.9
+    ) -> List[Any]:
+        """
+        Search for the top_k most similar vectors to the query vector.
+
+        Args:
+            query_vector (List[float]): The vector to query against the index.
+            top_k (int): Number of top results to return.
+            dis_threshold (float): Distance threshold below which results are 
considered relevant.
+
+        Returns:
+            List[Any]: List of properties of the matched vectors.
+        """
+
+    @abstractmethod
+    def save_index_by_name(self, *name: str):
+        """
+        #TODO: finish comment
+        """
+
+    @abstractmethod
+    def get_vector_index_info(
+        self,
+    ) -> Dict:
+        """
+        #TODO: finish comment
+        """
+
+    @staticmethod
+    @abstractmethod
+    def from_name(embed_dim: int, *name: str) -> "VectorStoreBase":
+        """
+        #TODO: finish comment

Review Comment:
   The docstring is incomplete. Consider documenting what `from_name` does, its 
parameters, and return value.
   ```suggestion
           Create and return an instance of a vector store by name.
   
           Args:
               embed_dim (int): The dimension of the embedding vectors.
               *name (str): One or more names identifying the vector store 
instance.
   
           Returns:
               VectorStoreBase: An instance of the vector store corresponding 
to the given name(s).
   ```



##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/base.py:
##########
@@ -0,0 +1,107 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+from abc import ABC, abstractmethod
+from typing import Any, Dict, List, Set, Union
+
+
+class VectorStoreBase(ABC):
+    """
+    Abstract base class defining the interface for a vector store.
+    Implementations must support adding, removing, searching vectors,
+    saving/loading from disk, and cleaning up resources.
+    """
+
+    @abstractmethod
+    def add(self, vectors: List[List[float]], props: List[Any]):
+        """
+        Add a list of vectors and their corresponding properties to the store.
+
+        Args:
+            vectors (List[List[float]]): List of embedding vectors.
+            props (List[Any]): List of associated metadata or properties for 
each vector.
+        """
+
+    @abstractmethod
+    def get_all_properties(self) -> list[str]:
+        """
+        #TODO: finish comment

Review Comment:
   The docstring is incomplete. Consider documenting what `get_all_properties` 
returns and its purpose.
   ```suggestion
           Retrieve all properties (identifiers or metadata) associated with 
the stored vectors.
   
           Returns:
               list[str]: A list of all properties currently stored in the 
vector index.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to