Closed axgabs closed 6 months ago
🤖
Hello,
Yes, it's possible to implement an exception treatment in LlamaIndex v0.8.29.post1 to handle a quota exceeded error when adding multiple nodes to a keyword index using the index.insert_nodes(node) function.
You can do this by adding a try/except block around the self._client.upsert
call in the add
method of the QdrantVectorStore
class. If a quota exceeded error is raised, you can catch it and handle it appropriately.
Here is an example of how you can do this:
from qdrant_client.http.exceptions import QuotaExceededError
def add(self, nodes: List[BaseNode]) -> List[str]:
"""Add nodes to index.
Args
nodes: List[BaseNode]: list of nodes with embeddings
"""
from qdrant_client.http import models as rest
if len(nodes) > 0 and not self._collection_initialized:
self._create_collection(
collection_name=self.collection_name,
vector_size=len(nodes[0].get_embedding()),
)
ids = []
for node_batch in iter_batch(nodes, self.batch_size):
node_ids = []
vectors = []
payloads = []
for node in node_batch:
assert isinstance(node, BaseNode)
node_ids.append(node.node_id)
vectors.append(node.get_embedding())
metadata = node_to_metadata_dict(
node, remove_text=False, flat_metadata=self.flat_metadata
)
payloads.append(metadata)
try:
self._client.upsert(
collection_name=self.collection_name,
points=rest.Batch.construct(
ids=node_ids,
vectors=vectors,
payloads=payloads,
),
)
except QuotaExceededError:
# Handle quota exceeded error here
logger.error("Quota exceeded when adding nodes to index")
break
ids.extend(node_ids)
return ids
In this example, if a QuotaExceededError
is raised during the self._client.upsert
call, the error is caught and a message is logged. The loop then breaks, stopping the addition of more nodes to the index. You can replace the logging statement with your own error handling code.
Regarding the exact error message that is being returned when the quota exceeded error occurs, could you please provide more details? This would help in understanding the issue better and providing a more accurate solution.
Best, Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Hi, @axgabs,
I'm helping the LlamaIndex team manage their backlog and am marking this issue as stale. From what I understand, you raised an issue regarding a quota exceeded error when adding nodes to a keyword index in llama-index-0.8.29.post1. It looks like I provided a detailed response suggesting the implementation of an exception treatment in LlamaIndex v0.8.29.post1 to handle the quota exceeded error, along with a code example demonstrating how to use a try/except block to catch the QuotaExceededError and handle it appropriately.
Could you please confirm if this issue is still relevant to the latest version of the LlamaIndex repository? If it is, please let the LlamaIndex team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.
Thank you for your understanding and cooperation. If you have any further questions or need assistance, feel free to reach out.
Bug Description
Different from vector index, when I try to add several nodes to a keyword index, it returns me a quota exceeded error. I wonder if it is possible to add a exception treatment which will wait some time and try again to add the remaining nodes.
Version
llama-index-0.8.29.post1
Steps to Reproduce
Use index.insert_nodes(node) several times.
Relevant Logs/Tracbacks