MemPalace/mempalace · error · ValueError

pgvector requires query_embeddings; use palace.get_collectio

Error message

pgvector requires query_embeddings; use palace.get_collection wrapper

What it means

The pgvector backend has no embedder attached, so it cannot turn query_texts into vectors. query() rejects any call that passes query_texts and tells you to obtain the collection through the palace.get_collection() wrapper, which wires up an embedder and converts texts to embeddings for you.

Source

Thrown at mempalace/backends/pgvector.py:1080

            ids=outer_ids,
            documents=outer_docs,
            metadatas=outer_metas,
            distances=outer_dists,
            embeddings=outer_embeds if spec.embeddings else None,
        )

    def query(
        self,
        *,
        query_texts=None,
        query_embeddings=None,
        n_results=10,
        where=None,
        where_document=None,
        include=None,
    ) -> QueryResult:
        if query_texts is not None:
            raise ValueError(
                "pgvector requires query_embeddings; use palace.get_collection wrapper"
            )
        if query_embeddings is None:
            raise ValueError("query requires query_embeddings")
        if not query_embeddings:
            raise ValueError("query input must be a non-empty list")
        _validate_where(where)
        _validate_where(where_document)
        if _requires_local_filter(where, where_document):
            return self._query_local_exact(
                query_embeddings=query_embeddings,
                n_results=n_results,
                where=where,
                where_document=where_document,
                include=include,
            )
        self._ensure_open()
        if not self._table_exists():

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Open the collection via palace.get_collection(...) and call query(query_texts=...) on that wrapper, which embeds the texts first.
  2. Or embed the texts yourself with your embedder and call query(query_embeddings=[...]) on the pgvector collection.
  3. Remove query_texts entirely if you already have embeddings.

Example fix

# before
col = pgvector_backend.get_collection(palace, "notes")
col.query(query_texts=["hello"], n_results=5)

# after
col = palace.get_collection("notes")
col.query(query_texts=["hello"], n_results=5)
Defensive patterns

Strategy: validation

Validate before calling

# use the palace wrapper, which embeds texts for you
col = palace.get_collection("notes")
col.query(query_texts=["hello"], n_results=5)

Try / catch

try:
    col.query(query_texts=["hello"])
except ValueError as e:
    if "use palace.get_collection wrapper" in str(e):
        col = palace.get_collection("notes")
        results = col.query(query_texts=["hello"])

Prevention

When it happens

Trigger: Calling PgVectorCollection.query(query_texts=["hello"]) directly, or piping a ChromaDB-style call with query_texts into a collection object obtained from the raw pgvector backend instead of palace.get_collection().

Common situations: Porting code written against ChromaDB (whose query accepts query_texts) to the pgvector backend; grabbing the collection from backend.get_collection() and assuming the same text-query surface.

Related errors


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/5728ab2f0d4477ea. Report an issue: GitHub.