bug(vector_stores/pinecone): OR / NOT 过滤器被发送为 {"$or": {"$eq": [...]}},每个这样的搜索都会以 HTTP 400 失败
import os os.environ["MEM0_TELEMETRY"] = "False" os.environ.setdefault("OPENAI_API_KEY", "sk-not-used")
from pinecone import Pinecone from mem0 import Memory
class _LocalClient: def init(self): self._pc = Pinecone(api_key="pclocal", host="http://localhost:5080")
def __getattr__(self, name):
return getattr(self._pc, name)
def Index(self, name):
return self._pc.Index(host="http://" + self._pc.describe_index(name).host)class _Emb: def embed(self, text, memory_action=None): return [1.0, 0.0]
m = Memory.from_config({ "vector_store": {"provider": "pinecone", "config": { "collection_name": "filters-probe", "embedding_model_dims": 2, "client": _LocalClient(), "serverless_config": {"cloud": "AWS", "region": "us-east-1"}}}, "history_db_path": ":memory:", }) m.embedding_model = _Emb() vs = m.vector_store try: vs.insert( vectors=[[1.0, 0.0], [0.99, 0.01], [0.98, 0.02], [0.97, 0.03]], payloads=[ {"data": "a", "user_id": "u1", "category": "food", "priority": 1}, {"data": "b", "user_id": "u1", "category": "travel", "priority": 5}, {"data": "c", "user_id": "u1", "category": "work", "priority": 9}, {"data": "d", "user_id": "u2", "category": "food", "priority": 1}, ], ids=["a", "b", "c", "d"], ) cases = [ ("in", {"user_id": "u1", "category": {"in": ["food", "travel"]}}), ("OR", {"user_id": "u1", "OR": [{"category": "food"}, {"category": "travel"}]}), ("NOT", {"user_id": "u1", "NOT": [{"category": "work"}]}), ("NOT range", {"user_id": "u1", "NOT": [{"priority": {"gte": 2, "lte": 6}}]}), ("OR + NOT", {"user_id": "u1", "OR": [{"priority": 1}, {"priority": 9}], "NOT": [{"category": "work"}]}), ] for label, filters in cases: try: …
内容来源: mem0ai/mem0