Expand description
SelfQueryRetriever — a self-querying retriever
Lets an LLM split a natural-language query into { query, filter }: the cleaned query
goes to vector retrieval, and the parsed MetadataFilter is handed to
vector_store.similarity_search_with_filter for metadata filtering (relying on S3’s
unified filtering capability). The split goes through lc_core::judge::structured_call
(binds a tool to get structured arguments, falling back to text parsing when the model
does not support it), the same execution path as Guardrails / Evaluation; the
allowed_attributes whitelist blocks the LLM from filtering on fields that do not exist.
No silent degradation: when a filter references a field outside the whitelist, it
explicitly returns RetrieverError::InvalidFilter rather than dropping the filter and
falling back to an unfiltered search — that would return data that should have been
filtered out (data-plane over-exposure). An empty whitelist = filtering is entirely
disabled: filters are always ignored with a warning (this is the established “disable
filtering” pattern, not silent degradation).
Structs§
- Self
Query Args - Structured parameters parsed by the LLM: the cleaned query + an optional metadata filter.
- Self
Query Retriever - Self-querying retriever: LLM splits the query -> whitelist validation -> filtered similarity search.