Skip to content

Commit 9d642f6

Browse files
rohithshenoytjbckjoaobackrohithshenoyg
authored
Added support for connecting to self hosted weaviate deployments using connect_to_custom replacing connect_to_local, which is better suited for cases where HTTP and GRPC are hosted on different ingresses. (open-webui#20620)
Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: joaoback <156559121+joaoback@users.noreply.github.com> Co-authored-by: rohithshenoyg@gmail.com <rohithshenoyg@gmail.com>
1 parent 716f298 commit 9d642f6

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

backend/open_webui/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,9 +2246,13 @@ class BannerModel(BaseModel):
22462246
QDRANT_COLLECTION_PREFIX = os.environ.get("QDRANT_COLLECTION_PREFIX", "open-webui")
22472247

22482248
WEAVIATE_HTTP_HOST = os.environ.get("WEAVIATE_HTTP_HOST", "")
2249+
WEAVIATE_GRPC_HOST = os.environ.get("WEAVIATE_GRPC_HOST", "")
22492250
WEAVIATE_HTTP_PORT = int(os.environ.get("WEAVIATE_HTTP_PORT", "8080"))
22502251
WEAVIATE_GRPC_PORT = int(os.environ.get("WEAVIATE_GRPC_PORT", "50051"))
22512252
WEAVIATE_API_KEY = os.environ.get("WEAVIATE_API_KEY")
2253+
WEAVIATE_HTTP_SECURE = os.environ.get("WEAVIATE_HTTP_SECURE", "false").lower() == "true"
2254+
WEAVIATE_GRPC_SECURE = os.environ.get("WEAVIATE_GRPC_SECURE", "false").lower() == "true"
2255+
WEAVIATE_SKIP_INIT_CHECKS = os.environ.get("WEAVIATE_SKIP_INIT_CHECKS", "false").lower() == "true"
22522256

22532257
# OpenSearch
22542258
OPENSEARCH_URI = os.environ.get("OPENSEARCH_URI", "https://localhost:9200")

backend/open_webui/retrieval/vector/dbs/weaviate.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
from open_webui.retrieval.vector.utils import process_metadata
1313
from open_webui.config import (
1414
WEAVIATE_HTTP_HOST,
15+
WEAVIATE_GRPC_HOST,
1516
WEAVIATE_HTTP_PORT,
1617
WEAVIATE_GRPC_PORT,
1718
WEAVIATE_API_KEY,
19+
WEAVIATE_HTTP_SECURE,
20+
WEAVIATE_GRPC_SECURE,
21+
WEAVIATE_SKIP_INIT_CHECKS,
1822
)
1923

2024

@@ -52,9 +56,13 @@ def __init__(self):
5256
try:
5357
# Build connection parameters
5458
connection_params = {
55-
"host": WEAVIATE_HTTP_HOST,
56-
"port": WEAVIATE_HTTP_PORT,
59+
"http_host": WEAVIATE_HTTP_HOST,
60+
"http_port": WEAVIATE_HTTP_PORT,
61+
"http_secure": WEAVIATE_HTTP_SECURE,
62+
"grpc_host": WEAVIATE_GRPC_HOST,
5763
"grpc_port": WEAVIATE_GRPC_PORT,
64+
"grpc_secure": WEAVIATE_GRPC_SECURE,
65+
"skip_init_checks": WEAVIATE_SKIP_INIT_CHECKS,
5866
}
5967

6068
# Only add auth_credentials if WEAVIATE_API_KEY exists and is not empty
@@ -63,7 +71,7 @@ def __init__(self):
6371
weaviate.classes.init.Auth.api_key(WEAVIATE_API_KEY)
6472
)
6573

66-
self.client = weaviate.connect_to_local(**connection_params)
74+
self.client = weaviate.connect_to_custom(**connection_params)
6775
self.client.connect()
6876
except Exception as e:
6977
raise ConnectionError(f"Failed to connect to Weaviate: {e}") from e

0 commit comments

Comments
 (0)