Python `v4` client - feedback megathread!

hi @zhou_yangbo !

You are probably initiating the v3 client and trying to run a v4 syntax.

Note that the v4 package has both v3 client and v4 client.

In order to use the v4 client, you must do this:

client = weaviate.connect_to_wcs(
    cluster_url=os.getenv("WCS_URL"),
    auth_credentials=weaviate.auth.AuthApiKey(os.getenv("WCS_API_KEY")),
    headers={
        "X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"]  # Replace with your inference API key
    }
)

this is how you initiate the v4 client.

For the v3 client, you can use the same package, but initialize it using:

client = weaviate.Client(
    url = "https://WEAVIATE_INSTANCE_URL",  # Replace with your Weaviate endpoint
    auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"),  # Replace with your Weaviate instance API key
    additional_headers = {
        "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY"  # Replace with your inference API key
    }
)

Not that you still get the client, but the first one is a v4 client, and the second one is a v3 client.

Let me know if this clarifies.

Thanks!

how about using it with local weaviate and local Ollama LLM without remote openAI? thanks.

just meets its no attribute ‘collections’, :frowning:

@zhou_yangbo ! There you go:

I will do an example (soon) with docker compose here:

1 Like

2 posts were split to a new topic: Dynamic any filter with Python v4 client