mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-02 01:23:07 +00:00
community[patch]: add delete() method to AzureSearch vector store (#21127)
**Issue:** Currently `AzureSearch` vector store does not implement `delete` method. This PR implements it. This also makes it compatible with LangChain indexer. **Dependencies:** None **Twitter handle:** @martintriska1 --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
3441a11b21
commit
0f7f448603
@ -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`, `CouchbaseVectorStore`, `DashVector`, `DatabricksVectorSearch`, `DeepLake`, `Dingo`, `ElasticVectorSearch`, `ElasticsearchStore`, `FAISS`, `HanaDB`, `LanceDB`, `Milvus`, `MyScale`, `OpenSearchVectorSearch`, `PGVector`, `Pinecone`, `Qdrant`, `Redis`, `Rockset`, `ScaNN`, `SupabaseVectorStore`, `SurrealDBStore`, `TimescaleVector`, `UpstashVectorStore`, `Vald`, `VDMS`, `Vearch`, `VespaStore`, `Weaviate`, `ZepVectorStore`, `TencentVectorDB`, `OpenSearchVectorSearch`.\n",
|
||||
"Compatible Vectorstores: `AnalyticDB`, `AstraDB`, `AzureCosmosDBVectorSearch`, `AzureSearch`, `AwaDB`, `Bagel`, `Cassandra`, `Chroma`, `CouchbaseVectorStore`, `DashVector`, `DatabricksVectorSearch`, `DeepLake`, `Dingo`, `ElasticVectorSearch`, `ElasticsearchStore`, `FAISS`, `HanaDB`, `LanceDB`, `Milvus`, `MyScale`, `OpenSearchVectorSearch`, `PGVector`, `Pinecone`, `Qdrant`, `Redis`, `Rockset`, `ScaNN`, `SupabaseVectorStore`, `SurrealDBStore`, `TimescaleVector`, `UpstashVectorStore`, `Vald`, `VDMS`, `Vearch`, `VespaStore`, `Weaviate`, `ZepVectorStore`, `TencentVectorDB`, `OpenSearchVectorSearch`.\n",
|
||||
" \n",
|
||||
"## Caution\n",
|
||||
"\n",
|
||||
|
@ -377,6 +377,22 @@ class AzureSearch(VectorStore):
|
||||
else:
|
||||
raise Exception(response)
|
||||
|
||||
def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> bool:
|
||||
"""Delete by vector ID.
|
||||
|
||||
Args:
|
||||
ids: List of ids to delete.
|
||||
|
||||
Returns:
|
||||
bool: True if deletion is successful,
|
||||
False otherwise.
|
||||
"""
|
||||
if ids:
|
||||
res = self.client.delete_documents([{"id": i} for i in ids])
|
||||
return len(res) > 0
|
||||
else:
|
||||
return False
|
||||
|
||||
def similarity_search(
|
||||
self, query: str, k: int = 4, **kwargs: Any
|
||||
) -> List[Document]:
|
||||
|
@ -16,7 +16,7 @@ def test_compatible_vectorstore_documentation() -> None:
|
||||
case and 1) update docs in [1] and 2) update the `documented`
|
||||
dict in this test case.
|
||||
|
||||
[1] langchain/docs/docs_skeleton/docs/modules/data_connection/indexing.ipynb
|
||||
[1] langchain/docs/docs/modules/data_connection/indexing.ipynb
|
||||
"""
|
||||
|
||||
# Check if a vectorstore is compatible with the indexing API
|
||||
@ -49,6 +49,7 @@ def test_compatible_vectorstore_documentation() -> None:
|
||||
"AnalyticDB",
|
||||
"AstraDB",
|
||||
"AzureCosmosDBVectorSearch",
|
||||
"AzureSearch",
|
||||
"AwaDB",
|
||||
"Bagel",
|
||||
"BESVectorStore",
|
||||
|
Loading…
Reference in New Issue
Block a user