Open torvalds-dev opened 1 year ago
torvalds.dev is analyzing the ticket
The task is to add an error statement when the deletion of a Pinecone index fails. The relevant files for this task are:
llama_index/readers/json.py
llama_index/vector_stores/pinecone.py
llama_index/readers/pinecone.py
The deletion of a Pinecone index is handled in the delete
method of the PineconeVectorStore
class in the llama_index/vector_stores/pinecone.py
file. Currently, there is no error handling in this method.
Here is a plan to add the error statement:
delete
method of the PineconeVectorStore
class, add a try-except block around the self._pinecone_index.delete
call.Here is the code snippet to add the error statement:
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.
"""
# delete by filtering on the doc_id metadata
try:
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 index with ref_doc_id {ref_doc_id}. Error: {str(e)}")
This code will log an error message when the deletion of a Pinecone index fails. The error message will include the ref_doc_id
of the index that failed to be deleted and the details of the exception.
Question Validation
Question
Add error statement when pinecone index deletion fails