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.

feat: optimize weaviate error msg (#441)

John Wang951afcaaed2b
diff --git a/api/core/index/vector_index/weaviate_vector_index.py b/api/core/index/vector_index/weaviate_vector_index.py
index e9eae4468cf..df12dd9c534 100644
--- a/api/core/index/vector_index/weaviate_vector_index.py
+++ b/api/core/index/vector_index/weaviate_vector_index.py
@@ -1,5 +1,6 @@
from typing import Optional, cast
+import requests
import weaviate
from langchain.embeddings.base import Embeddings
from langchain.schema import Document, BaseRetriever
@@ -34,12 +35,15 @@ class WeaviateVectorIndex(BaseVectorIndex):
weaviate.connect.connection.has_grpc = False
- client = weaviate.Client(
- url=config.endpoint,
- auth_client_secret=auth_config,
- timeout_config=(5, 60),
- startup_period=None
- )
+ try:
+ client = weaviate.Client(
+ url=config.endpoint,
+ auth_client_secret=auth_config,
+ timeout_config=(5, 60),
+ startup_period=None
+ )
+ except requests.exceptions.ConnectionError:
+ raise ConnectionError("Vector database connection error")
client.batch.configure(
# `batch_size` takes an `int` value to enable auto-batching