Commit d1ccbfe
feat: Enable Filters in OpenAI Search API (#4471)
# What does this PR do?
Finishes #2435; i.e.,
adds support for OpenAI Search API typed filters for vector IO.
This PR adds support for OpenAI's typed metadata filter API across
vector IO providers, enabling callers to filter search results by
metadata fields using comparison operators (eq, ne, gt, gte, lt, lte,
in, nin) and compound logic (and, or).
Core changes:
- API & routing (core/routers/vector_io.py): Propagates filter
parameters from the query request through the provider dispatch layer.
- Filter type definitions (providers/utils/vector_io/filters.py):
Introduces ComparisonFilter, CompoundFilter, and Filter union type used
across all providers.
- Inline providers (faiss, sqlite-vec): Implement filter evaluation
in-memory (faiss) and via SQL WHERE clauses using JSON_EXTRACT
(sqlite-vec). Operator dispatch uses a module-level `COMPARISON_OPS` /
`SQL_OPS` dict instead of if/elif chains.
- Remote providers (Milvus, Chroma, Elasticsearch, pgvector, Qdrant,
Weaviate, OCI): Translate filters to each backend's native expression or
query language.
- OpenAI vector store mixin (openai_vector_store_mixin.py):
Post-retrieval Python-side filter evaluation using a shared
COMPARISON_OPERATORS dispatch dict, covering providers that don't
support server-side filtering natively.
- Milvus bug fix: filter parameter was not being passed to keyword
search — corrected.
## Test Plan
- New integration test suite:
tests/integration/vector_io/test_vector_io_filters.py — covers all 8
comparison operators and compound (and/or) logic
against faiss and sqlite-vec
- New integration test:
test_openai_vector_store_search_with_typed_filters in
test_openai_vector_stores.py — validates eq/lte/compound-or filters over
the OpenAI vector store path
- Run integration tests locally via:
### faiss
.venv/bin/python -m pytest
tests/integration/vector_io/test_vector_io_filters.py \
--stack-config="inference=inline::sentence-transformers,vector_io=inline::faiss,files=inline::localfs"
-v
### sqlite-vec
.venv/bin/python -m pytest
tests/integration/vector_io/test_vector_io_filters.py \
--stack-config="inference=inline::sentence-transformers,vector_io=inline::sqlite-vec,files=inline::localfs"
-v
#### OpenAI vector store filter (mixin path)
.venv/bin/python -m pytest
tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_search_with_typed_filters
\
--stack-config="inference=inline::sentence-transformers,vector_io=inline::sqlite-vec,files=inline::localfs"
-v
---------
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
Co-authored-by: Claude Sonnet 4 <noreply@anthropic.com>1 parent 756b8b7 commit d1ccbfe
25 files changed
Lines changed: 2204 additions & 232 deletions
File tree
- client-sdks/stainless
- docs/static
- src
- llama_stack_api
- llama_stack
- core/routers
- providers
- inline/vector_io
- faiss
- sqlite_vec
- remote/vector_io
- chroma
- elasticsearch
- milvus
- oci
- pgvector
- qdrant
- weaviate
- utils
- memory
- vector_io
- tests
- integration/vector_io
- unit/providers/vector_io
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15651 | 15651 | | |
15652 | 15652 | | |
15653 | 15653 | | |
| 15654 | + | |
| 15655 | + | |
| 15656 | + | |
| 15657 | + | |
| 15658 | + | |
| 15659 | + | |
| 15660 | + | |
| 15661 | + | |
| 15662 | + | |
| 15663 | + | |
| 15664 | + | |
| 15665 | + | |
| 15666 | + | |
| 15667 | + | |
| 15668 | + | |
| 15669 | + | |
| 15670 | + | |
| 15671 | + | |
| 15672 | + | |
| 15673 | + | |
| 15674 | + | |
| 15675 | + | |
| 15676 | + | |
| 15677 | + | |
| 15678 | + | |
| 15679 | + | |
| 15680 | + | |
| 15681 | + | |
| 15682 | + | |
| 15683 | + | |
| 15684 | + | |
| 15685 | + | |
| 15686 | + | |
| 15687 | + | |
| 15688 | + | |
| 15689 | + | |
| 15690 | + | |
| 15691 | + | |
| 15692 | + | |
| 15693 | + | |
| 15694 | + | |
| 15695 | + | |
| 15696 | + | |
| 15697 | + | |
15654 | 15698 | | |
15655 | 15699 | | |
15656 | 15700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12197 | 12197 | | |
12198 | 12198 | | |
12199 | 12199 | | |
| 12200 | + | |
| 12201 | + | |
| 12202 | + | |
| 12203 | + | |
| 12204 | + | |
| 12205 | + | |
| 12206 | + | |
| 12207 | + | |
| 12208 | + | |
| 12209 | + | |
| 12210 | + | |
| 12211 | + | |
| 12212 | + | |
| 12213 | + | |
| 12214 | + | |
| 12215 | + | |
| 12216 | + | |
| 12217 | + | |
| 12218 | + | |
| 12219 | + | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
| 12223 | + | |
| 12224 | + | |
| 12225 | + | |
| 12226 | + | |
| 12227 | + | |
| 12228 | + | |
| 12229 | + | |
| 12230 | + | |
| 12231 | + | |
| 12232 | + | |
| 12233 | + | |
| 12234 | + | |
| 12235 | + | |
| 12236 | + | |
| 12237 | + | |
| 12238 | + | |
| 12239 | + | |
| 12240 | + | |
| 12241 | + | |
| 12242 | + | |
| 12243 | + | |
12200 | 12244 | | |
12201 | 12245 | | |
12202 | 12246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11935 | 11935 | | |
11936 | 11936 | | |
11937 | 11937 | | |
| 11938 | + | |
| 11939 | + | |
| 11940 | + | |
| 11941 | + | |
| 11942 | + | |
| 11943 | + | |
| 11944 | + | |
| 11945 | + | |
| 11946 | + | |
| 11947 | + | |
| 11948 | + | |
| 11949 | + | |
| 11950 | + | |
| 11951 | + | |
| 11952 | + | |
| 11953 | + | |
| 11954 | + | |
| 11955 | + | |
| 11956 | + | |
| 11957 | + | |
| 11958 | + | |
| 11959 | + | |
| 11960 | + | |
| 11961 | + | |
| 11962 | + | |
| 11963 | + | |
| 11964 | + | |
| 11965 | + | |
| 11966 | + | |
| 11967 | + | |
| 11968 | + | |
| 11969 | + | |
| 11970 | + | |
| 11971 | + | |
| 11972 | + | |
| 11973 | + | |
| 11974 | + | |
| 11975 | + | |
| 11976 | + | |
| 11977 | + | |
| 11978 | + | |
| 11979 | + | |
| 11980 | + | |
| 11981 | + | |
11938 | 11982 | | |
11939 | 11983 | | |
11940 | 11984 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14006 | 14006 | | |
14007 | 14007 | | |
14008 | 14008 | | |
| 14009 | + | |
| 14010 | + | |
| 14011 | + | |
| 14012 | + | |
| 14013 | + | |
| 14014 | + | |
| 14015 | + | |
| 14016 | + | |
| 14017 | + | |
| 14018 | + | |
| 14019 | + | |
| 14020 | + | |
| 14021 | + | |
| 14022 | + | |
| 14023 | + | |
| 14024 | + | |
| 14025 | + | |
| 14026 | + | |
| 14027 | + | |
| 14028 | + | |
| 14029 | + | |
| 14030 | + | |
| 14031 | + | |
| 14032 | + | |
| 14033 | + | |
| 14034 | + | |
| 14035 | + | |
| 14036 | + | |
| 14037 | + | |
| 14038 | + | |
| 14039 | + | |
| 14040 | + | |
| 14041 | + | |
| 14042 | + | |
| 14043 | + | |
| 14044 | + | |
| 14045 | + | |
| 14046 | + | |
| 14047 | + | |
| 14048 | + | |
| 14049 | + | |
| 14050 | + | |
| 14051 | + | |
| 14052 | + | |
14009 | 14053 | | |
14010 | 14054 | | |
14011 | 14055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15651 | 15651 | | |
15652 | 15652 | | |
15653 | 15653 | | |
| 15654 | + | |
| 15655 | + | |
| 15656 | + | |
| 15657 | + | |
| 15658 | + | |
| 15659 | + | |
| 15660 | + | |
| 15661 | + | |
| 15662 | + | |
| 15663 | + | |
| 15664 | + | |
| 15665 | + | |
| 15666 | + | |
| 15667 | + | |
| 15668 | + | |
| 15669 | + | |
| 15670 | + | |
| 15671 | + | |
| 15672 | + | |
| 15673 | + | |
| 15674 | + | |
| 15675 | + | |
| 15676 | + | |
| 15677 | + | |
| 15678 | + | |
| 15679 | + | |
| 15680 | + | |
| 15681 | + | |
| 15682 | + | |
| 15683 | + | |
| 15684 | + | |
| 15685 | + | |
| 15686 | + | |
| 15687 | + | |
| 15688 | + | |
| 15689 | + | |
| 15690 | + | |
| 15691 | + | |
| 15692 | + | |
| 15693 | + | |
| 15694 | + | |
| 15695 | + | |
| 15696 | + | |
| 15697 | + | |
15654 | 15698 | | |
15655 | 15699 | | |
15656 | 15700 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
146 | 170 | | |
147 | 171 | | |
148 | 172 | | |
| |||
0 commit comments