diff --git a/docs/docs/community/integrations/vector_stores.md b/docs/docs/community/integrations/vector_stores.md index 3b951fe85fcaf..fcfe176e8acb7 100644 --- a/docs/docs/community/integrations/vector_stores.md +++ b/docs/docs/community/integrations/vector_stores.md @@ -762,8 +762,10 @@ resource_owner_config = weaviate.AuthClientPassword( username="", password="", ) -client = weaviate.Client( - "https://.semi.network/", +client = weaviate.WeaviateClient( + connection_params=weaviate.connect.ConnectionParams.from_url( + url="https://.semi.network/", grpc_port=50051 + ), auth_client_secret=resource_owner_config, ) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/base.py index 25a4bd9358f7c..d2cc006754219 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/base.py @@ -34,12 +34,12 @@ import weaviate import weaviate.classes as wvc - from weaviate.collections.batch.batch_wrapper import ( _ContextManagerWrapper as BatchWrapper, ) _logger = logging.getLogger(__name__) +_WEAVIATE_DEFAULT_GRPC_PORT = 50051 def _transform_weaviate_filter_condition(condition: str) -> str: @@ -127,14 +127,19 @@ class WeaviateVectorStore(BasePydanticVectorStore): `pip install llama-index-vector-stores-weaviate` ```python + from llama_index.vector_stores.weaviate import WeaviateVectorStore import weaviate - resource_owner_config = weaviate.AuthClientPassword( + resource_owner_config = weaviate.auth.AuthClientPassword( username="", password="", ) - client = weaviate.Client( - "https://llama-test-ezjahb4m.weaviate.network", + connection_params = weaviate.connect.ConnectionParams.from_url( + url="https://llama-test-ezjahb4m.weaviate.network", + grpc_port=50051, + ) + client = weaviate.WeaviateClient( + connection_params=connection_params, auth_client_secret=resource_owner_config, ) @@ -163,7 +168,7 @@ class WeaviateVectorStore(BasePydanticVectorStore): def __init__( self, - weaviate_client: Optional[Any] = None, + weaviate_client: Optional[weaviate.WeaviateClient] = None, class_prefix: Optional[str] = None, index_name: Optional[str] = None, text_key: str = DEFAULT_TEXT_KEY, diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/utils.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/utils.py index 900624003c482..3edf619e37676 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/utils.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-weaviate/llama_index/vector_stores/weaviate/utils.py @@ -47,13 +47,15 @@ def validate_client(client: Any) -> None: """Validate client and import weaviate library.""" try: import weaviate - - client = cast(weaviate.WeaviateClient, client) except ImportError: raise ImportError( "Weaviate is not installed. " "Please install it with `pip install weaviate-client`." ) + if not isinstance(client, weaviate.WeaviateClient): + raise ValueError( + f"Invalid client type, expected weaviate.WeaviateClient, got {type(client)}" + ) cast(weaviate.WeaviateClient, client)