Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Refactor BaseVectorIndex delete method (#1853)

waltcow06d2d8cea339
diff --git a/api/core/index/vector_index/base.py b/api/core/index/vector_index/base.py
index bc7811a0e2a..1775ff3edfc 100644
--- a/api/core/index/vector_index/base.py
+++ b/api/core/index/vector_index/base.py
@@ -6,7 +6,6 @@ from typing import List, Any, cast
from langchain.embeddings.base import Embeddings
from langchain.schema import Document, BaseRetriever
from langchain.vectorstores import VectorStore
-from weaviate import UnexpectedStatusCodeException
from core.index.base import BaseIndex
from extensions.ext_database import db
@@ -139,10 +138,8 @@ class BaseVectorIndex(BaseIndex):
try:
self.delete()
- except UnexpectedStatusCodeException as e:
- if e.status_code != 400:
- # 400 means index not exists
- raise e
+ except Exception as e:
+ raise e
dataset_documents = db.session.query(DatasetDocument).filter(
DatasetDocument.dataset_id == dataset.id,
@@ -194,10 +191,8 @@ class BaseVectorIndex(BaseIndex):
try:
self.delete()
- except UnexpectedStatusCodeException as e:
- if e.status_code != 400:
- # 400 means index not exists
- raise e
+ except Exception as e:
+ raise e
dataset_documents = db.session.query(DatasetDocument).filter(
DatasetDocument.dataset_id == dataset.id,