torvalds-dev / llama_index

LlamaIndex (formerly GPT Index) is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
0 stars 0 forks source link

[Feature Request]: Add error statement when pinecone index deletion fails #7

Open torvalds-dev opened 10 months ago

torvalds-dev commented 10 months ago

Feature Description

Add error statement when pinecone index deletion fails

Reason

No response

Value of Feature

No response

torvalds-dev commented 10 months ago

torvalds.dev is analyzing the ticket

torvalds-dev commented 10 months ago

The issue "[Feature Request]: Add error statement when pinecone index deletion fails" suggests that there is a need for an error statement when the deletion of a Pinecone index fails. This is likely to provide more informative feedback to the user when an operation does not succeed as expected.

From the code provided, the relevant file and class for this issue is llama_index/vector_stores/pinecone.py in the PineconeVectorStore class. Specifically, the delete method in this class is responsible for deleting nodes from the Pinecone index.

Currently, the delete method does not provide any feedback if the deletion operation fails. It simply calls the delete method on the _pinecone_index object without any error handling or logging.

To address this issue, the following actions could be taken:

  1. Add error handling to the delete method in the PineconeVectorStore class. This could involve wrapping the call to _pinecone_index.delete in a try-except block and logging an error message if an exception is raised.

  2. The error message should provide details about the ref_doc_id that was attempted to be deleted. This will help in identifying which specific operation failed.

  3. It might also be helpful to log the exception message itself, as this could provide more details about why the deletion failed.

  4. If the Pinecone API provides any specific error codes or types for failed deletions, these could be used to provide more specific error messages.

  5. After making these changes, ensure to test the delete method with both valid and invalid ref_doc_id values to confirm that the error handling and logging is working as expected.

Here is a rough example of what the updated delete method might look like:

def delete(self, ref_doc_id: str, **delete_kwargs: Any) -> None:
    """
    Delete nodes using with ref_doc_id.

    Args:
        ref_doc_id (str): The doc_id of the document to delete.

    """
    try:
        # delete by filtering on the doc_id metadata
        self._pinecone_index.delete(
            filter={"doc_id": {"$eq": ref_doc_id}},
            namespace=self.namespace,
            **delete_kwargs,
        )
    except Exception as e:
        _logger.error(f"Failed to delete ref_doc_id {ref_doc_id} from Pinecone index. Error: {str(e)}")

This is just a basic example and the actual implementation might need to be adjusted based on the specifics of the Pinecone API and the logging practices in the rest of the project.