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. (#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>
This commit is contained in:
co-authored by
Tim Baek
joaoback
rohithshenoyg@gmail.com
parent
716f2986b9
commit
9d642f6354
@@ -2246,9 +2246,13 @@ ENABLE_QDRANT_MULTITENANCY_MODE = (
|
|||||||
QDRANT_COLLECTION_PREFIX = os.environ.get("QDRANT_COLLECTION_PREFIX", "open-webui")
|
QDRANT_COLLECTION_PREFIX = os.environ.get("QDRANT_COLLECTION_PREFIX", "open-webui")
|
||||||
|
|
||||||
WEAVIATE_HTTP_HOST = os.environ.get("WEAVIATE_HTTP_HOST", "")
|
WEAVIATE_HTTP_HOST = os.environ.get("WEAVIATE_HTTP_HOST", "")
|
||||||
|
WEAVIATE_GRPC_HOST = os.environ.get("WEAVIATE_GRPC_HOST", "")
|
||||||
WEAVIATE_HTTP_PORT = int(os.environ.get("WEAVIATE_HTTP_PORT", "8080"))
|
WEAVIATE_HTTP_PORT = int(os.environ.get("WEAVIATE_HTTP_PORT", "8080"))
|
||||||
WEAVIATE_GRPC_PORT = int(os.environ.get("WEAVIATE_GRPC_PORT", "50051"))
|
WEAVIATE_GRPC_PORT = int(os.environ.get("WEAVIATE_GRPC_PORT", "50051"))
|
||||||
WEAVIATE_API_KEY = os.environ.get("WEAVIATE_API_KEY")
|
WEAVIATE_API_KEY = os.environ.get("WEAVIATE_API_KEY")
|
||||||
|
WEAVIATE_HTTP_SECURE = os.environ.get("WEAVIATE_HTTP_SECURE", "false").lower() == "true"
|
||||||
|
WEAVIATE_GRPC_SECURE = os.environ.get("WEAVIATE_GRPC_SECURE", "false").lower() == "true"
|
||||||
|
WEAVIATE_SKIP_INIT_CHECKS = os.environ.get("WEAVIATE_SKIP_INIT_CHECKS", "false").lower() == "true"
|
||||||
|
|
||||||
# OpenSearch
|
# OpenSearch
|
||||||
OPENSEARCH_URI = os.environ.get("OPENSEARCH_URI", "https://localhost:9200")
|
OPENSEARCH_URI = os.environ.get("OPENSEARCH_URI", "https://localhost:9200")
|
||||||
|
|||||||
@@ -12,9 +12,13 @@ from open_webui.retrieval.vector.main import (
|
|||||||
from open_webui.retrieval.vector.utils import process_metadata
|
from open_webui.retrieval.vector.utils import process_metadata
|
||||||
from open_webui.config import (
|
from open_webui.config import (
|
||||||
WEAVIATE_HTTP_HOST,
|
WEAVIATE_HTTP_HOST,
|
||||||
|
WEAVIATE_GRPC_HOST,
|
||||||
WEAVIATE_HTTP_PORT,
|
WEAVIATE_HTTP_PORT,
|
||||||
WEAVIATE_GRPC_PORT,
|
WEAVIATE_GRPC_PORT,
|
||||||
WEAVIATE_API_KEY,
|
WEAVIATE_API_KEY,
|
||||||
|
WEAVIATE_HTTP_SECURE,
|
||||||
|
WEAVIATE_GRPC_SECURE,
|
||||||
|
WEAVIATE_SKIP_INIT_CHECKS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,9 +56,13 @@ class WeaviateClient(VectorDBBase):
|
|||||||
try:
|
try:
|
||||||
# Build connection parameters
|
# Build connection parameters
|
||||||
connection_params = {
|
connection_params = {
|
||||||
"host": WEAVIATE_HTTP_HOST,
|
"http_host": WEAVIATE_HTTP_HOST,
|
||||||
"port": WEAVIATE_HTTP_PORT,
|
"http_port": WEAVIATE_HTTP_PORT,
|
||||||
|
"http_secure": WEAVIATE_HTTP_SECURE,
|
||||||
|
"grpc_host": WEAVIATE_GRPC_HOST,
|
||||||
"grpc_port": WEAVIATE_GRPC_PORT,
|
"grpc_port": WEAVIATE_GRPC_PORT,
|
||||||
|
"grpc_secure": WEAVIATE_GRPC_SECURE,
|
||||||
|
"skip_init_checks": WEAVIATE_SKIP_INIT_CHECKS,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Only add auth_credentials if WEAVIATE_API_KEY exists and is not empty
|
# Only add auth_credentials if WEAVIATE_API_KEY exists and is not empty
|
||||||
@@ -63,7 +71,7 @@ class WeaviateClient(VectorDBBase):
|
|||||||
weaviate.classes.init.Auth.api_key(WEAVIATE_API_KEY)
|
weaviate.classes.init.Auth.api_key(WEAVIATE_API_KEY)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.client = weaviate.connect_to_local(**connection_params)
|
self.client = weaviate.connect_to_custom(**connection_params)
|
||||||
self.client.connect()
|
self.client.connect()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ConnectionError(f"Failed to connect to Weaviate: {e}") from e
|
raise ConnectionError(f"Failed to connect to Weaviate: {e}") from e
|
||||||
|
|||||||
Reference in New Issue
Block a user