Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Inconsistent use of v3 and v4 Weaviate clients #13719

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/docs/community/integrations/vector_stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,10 @@ resource_owner_config = weaviate.AuthClientPassword(
username="<username>",
password="<password>",
)
client = weaviate.Client(
"https://<cluster-id>.semi.network/",
client = weaviate.WeaviateClient(
connection_params=weaviate.connect.ConnectionParams.from_url(
url="https://<cluster-id>.semi.network/", grpc_port=50051
),
auth_client_secret=resource_owner_config,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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="<username>",
password="<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,
)

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is slightly out of date -- you can technically pass in an async client or sync client these days. This would break that

cast(weaviate.WeaviateClient, client)


Expand Down