Find answers from the community

Updated 3 months ago

Hey all, anybody been using Auto

Hey all, anybody been using Auto Retrieval lately?

The standard prompt seems to assume different filteres are joined by OR, but the actual filtering code in the VectorStoreIndex does this:

Plain Text
def _build_metadata_filter_fn(
    metadata_lookup_fn: Callable[[str], Mapping[str, Any]],
    metadata_filters: Optional[MetadataFilters] = None,
) -> Callable[[str], bool]:
    """Build metadata filter function."""
    filter_list = metadata_filters.legacy_filters() if metadata_filters else []
    if not filter_list:
        return lambda _: True

    def filter_fn(node_id: str) -> bool:
        metadata = metadata_lookup_fn(node_id)
        for filter_ in filter_list:
            metadata_value = metadata.get(filter_.key, None)
            if metadata_value is None:
                return False
            elif isinstance(metadata_value, list):
                if filter_.value not in metadata_value:
                    return False
            elif isinstance(metadata_value, (int, float, str, bool)):
                if metadata_value != filter_.value:
                    return False
        return True

    return filter_fn


...which definitely looks like AND to me. Is this by design?
L
2 comments
Some vector stores support OR but yea, most likely on oversight in the prompt
tbh that above code could also be update for SimpleVectorStore
Add a reply
Sign up and join the conversation on Discord