Description
Here’s the rewritten bug report in the requested template format:
Is this a new bug?
• I believe this is a new bug
• I have searched the existing Github issues and Community Forum, and I could not find an existing post for this bug
Describe the bug
The $and operator in the metadata filter for assistant.chat_completions appears to cause a 400 Client Error. This issue contradicts the documentation, which suggests that $and should be supported (as per https://www.pinecone.io/learn/assistant-api-deep-dive/#Using-Metadata).
Error information
The API returns the following error:
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://prod-1-data.ke.pinecone.io/assistant/chat/test/chat/completions
...
ValueError: Error in chat completions streaming: 400 Client Error: Bad Request for url: https://prod-1-data.ke.pinecone.io/assistant/chat/test/chat/completions
Relevant code snippet:
metadata_filter = {
"$and": [
{"date": {"$gte": 1698969600}}, # Unix timestamp for 2023-11-03
{"date": {"$lte": 1699142400}} # Unix timestamp for 2023-11-05
]
}
response = assistant.chat_completions(
messages=chat_context,
stream=True,
filter=metadata_filter
)
File metadata used for testing:
[FileModel(name='file-4.txt', id='66228d1a-ac09-408c-be81-bb39cee82b0f', metadata={'date': 1699056000.0, 'source': 'test/file-4.txt'}, ...),
FileModel(name='file-5.txt', id='a294006d-8d5f-45ff-ab90-9873467a4ae9', metadata={'date': 1699142400.0, 'source': 'test/file-5.txt'}, ...),
FileModel(name='file-3.txt', id='c6d652d8-a356-4d10-b1bb-5808b8b7cad5', metadata={'date': 1698969600.0, 'source': 'test/file-3.txt'}, ...)]
Steps to reproduce the issue locally
1. Set up a metadata filter using the $and operator:
metadata_filter = {
"$and": [
{"date": {"$gte": 1698969600}},
{"date": {"$lte": 1699142400}}
]
}
2. Call assistant.chat_completions with the filter.
3. Observe the 400 Client Error returned by the API.
Environment
• OS Version: macOS 14.4.1
• Python version: 3.11
• Python SDK version: Pinecone: 5.4.2, Pinecone-plugin-assistant: 0.4.3
Additional context
The documentation explicitly mentions $and as a valid operator, but it does not seem to function as expected in practice. Please confirm if this is a documentation error, an implementation bug, or an unsupported feature.