-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[Bug]: weaviate client has no collection attributes #13614
Comments
The error To resolve this issue, update the code to use the
def class_schema_exists(client: weaviate.Client, class_name: str) -> bool:
"""Check if class schema exists."""
validate_client(client)
return client.schema.exists(class_name)
def delete_index(self) -> None:
"""Delete the index associated with the client.
Raises:
- Exception: If the deletion fails, for some reason.
"""
if not class_schema_exists(self._client, self.index_name):
_logger.warning(
f"Index '{self.index_name}' does not exist. No action taken."
)
return
try:
self._client.schema.delete_class(self.index_name)
_logger.info(f"Successfully deleted index '{self.index_name}'.")
except Exception as e:
_logger.error(f"Failed to delete index '{self.index_name}': {e}")
raise Exception(f"Failed to delete index '{self.index_name}': {e}")
from llama_index.vector_stores.weaviate import WeaviateVectorStore
import weaviate
weaviate_url = "http://localhost:8080"
resource_owner_config = weaviate.AuthClientPassword(
username="<your-username>",
password="<your-password>",
)
client = weaviate.Client(
weaviate_url,
auth_client_secret=resource_owner_config,
)
vector_store = WeaviateVectorStore(
weaviate_client=client, index_name="<your-index-name>"
) Additionally, ensure that you are using the correct versions of the dependencies:
You can install the required packages using: pip install llama-index-vector-stores-weaviate weaviate-client This should resolve the issue and allow you to use the
|
Do note that collection is also called in this function - link, where
|
I'm also hitting this with dependencies: |
Looks like this is a user error, apologies. I was attempting to use a weaviate v3 client ( from llama_index.vector_stores.weaviate import WeaviateVectorStore
import weaviate
client = weaviate.connect_to_local()
vector_store = WeaviateVectorStore(weaviate_client=client) |
@arsyad2281 from your issue description, it looks like you made the same mistake I did. Change your code as per my comment above and you should be good. |
On closer inspection I realised that the |
I just ran into a similar issue, where I try to ingest modified files into my Weaviate database, so basically doing an upsert. I think it's caused by the The error I get: Traceback (most recent call last):
File "/foo/bar.py", line 56, in <module>
nodes = pipeline.run(documents=documents)
File "/home/krisz/.pyenv/versions/3.10.13/lib/python3.10/site-packages/llama_index/core/ingestion/pipeline.py", line 682, in run
nodes_to_run = self._handle_upserts(
File "/home/krisz/.pyenv/versions/3.10.13/lib/python3.10/site-packages/llama_index/core/ingestion/pipeline.py", line 612, in _handle_upserts
self.vector_store.delete(ref_doc_id)
File "/home/krisz/.pyenv/versions/3.10.13/lib/python3.10/site-packages/llama_index/vector_stores/weaviate/base.py", line 261, in delete
self._client.query.get(self.index_name)
AttributeError: 'WeaviateClient' object has no attribute 'query' The relevant part in query = (
self._client.query.get(self.index_name)
.with_additional(["id"])
.with_where(where_filter)
.with_limit(10000) # 10,000 is the max weaviate can fetch
) The |
@krisz094 thanks for pointing that out. I've pushed a commit dc8f15e to #13719 which fixes the Weaviate and LlamaIndex code bases are both very new to me; I've based my fix for the |
Just following up on this... I've now manually tested all public methods of the Any timeline for a review from any of the core contributors? |
#13365 should fix delete method @chrisk314 |
@brenkehoe ok thanks for pointing that out. I've now merged the latest changes from main into #13719 taking the |
Bug Description
I am initializing
WeaviateVectorStore
based on the example given in this linkHowever, I am getting this error:
AttributeError: 'Client' object has no attribute 'collections'
Python Version - 3.11.9
Version of llama index and relevant packages
llama-index==0.10.37
llama-index-vector-stores-weaviate==1.0.0
Version
0.10.37
Steps to Reproduce
Please replace
<your-username>
,<your-password>
and<your-index-name>
accordingly.WeaviateDB is locally hosted through docker with this image:
semitechnologies/weaviate:1.23.9
Relevant Logs/Tracbacks
The text was updated successfully, but these errors were encountered: