Commit 5d63477
fix: address unresolved review comments from PyPDF File Processor PR#4743 (#5173)
# What does this PR do?
Addresses remaining unresolved review comments from PR #4743 (PyPDF File
Processor integration) to ensure the file processing pipeline is
consistent, correctly typed, and aligned with API expectations.
**Key changes:**
- **Remove legacy chunking fallback:** Eliminate the
`_legacy_chunk_file` method and all fallback paths from
`OpenAIVectorStoreMixin`. The system now raises a clear `RuntimeError`
if `file_processor_api` is not configured, instead of silently degrading
to legacy inline parsing.
- **Wire `file_processor_api` through all vector_io providers:** Add
`Api.file_processors` to `optional_api_dependencies` in the registry,
pass it through all 12 factory functions, and accept/forward it in all 9
adapter constructors.
- **Make `files_api` required in PyPDF constructors:** Remove the
default `None` from both `PyPDFFileProcessorAdapter` and
`PyPDFFileProcessor`, and use `deps[Api.files]` (bracket access) in the
factory to fail fast if somehow missing.
- **Bounded file reads:** Implemented chunked reading for direct uploads
to cap memory usage, and add a size check on the `file_id` retrieval
path against `max_file_size_bytes`.
- **Clear error for missing `file_id`:** Wrap `openai_retrieve_file` in
a `try/except` that surfaces a `ValueError("File with id '...' not
found")`, with a new test covering this case.
- **Conditional text cleaning:** Make the `.strip()` whitespace-only
page filter conditional on the `clean_text` config setting.
- **Dead code cleanup:** Remove unused `file_processor_api` field from
`VectorStoreWithIndex` and the now-unused `make_overlapped_chunks`
import from the mixin.
Closes #4743
## Test Plan
### Automated tests
**1. Unit tests (mixin + vector_io)**
```bash
KMP_DUPLICATE_LIB_OK=TRUE uv run --group unit pytest -sv tests/unit/
```
All `test_contextual_retrieval.py` (16 tests) and
`test_vector_store_config_registration.py` tests — these exercise the
refactored `OpenAIVectorStoreMixin`.
**2. PyPDF file processor tests (20/20 pass)**
```bash
uv run --group test pytest -sv tests/integration/file_processors/test_pypdf_processor.py
```
**3. Full integration suite (replay mode)**
```bash
uv run --group test pytest -sv tests/integration/ --stack-config=starter
```
Result: **4 failed, 54 passed, 639 skipped, 1 xfailed**
All 4 failures are pre-existing and unrelated:
- `test_safety_with_image` — Pydantic schema mismatch (`type: 'image'`
vs `'image_url'`)
- `test_starter_distribution_config_loads_and_resolves` /
`test_postgres_demo_distribution_config_loads` — relative path
`FileNotFoundError`
- `test_mcp_tools_list_with_schemas` — no local MCP server (`Connection
refused`)
No regressions in vector_io, file_search, or ingestion workflows.
### Manual E2E verification (with starter distro)
```bash
export OLLAMA_URL="http://localhost:11434/v1"
llama stack run starter
```
**1. Verify route is registered:**
```bash
curl -sS http://localhost:8321/v1/inspect/routes \
| jq -r '.data[] | select(.route|test("file-processors";"i"))'
```
Expected:
```json
{
"route": "/v1alpha/file-processors/process",
"method": "POST",
"provider_types": [
"inline::pypdf"
]
}
```
**2. Verify OpenAPI contains the endpoint:**
```bash
curl -sS http://localhost:8321/openapi.json | rg -n "/v1alpha/file-processors/process|file-processors" -i
```
**3. Direct file upload:**
```bash
curl -sS -X POST http://localhost:8321/v1alpha/file-processors/process \
-F "file=@/path/to/sample.pdf" | jq
```
Expected: chunks response with `metadata.processor = "pypdf"`.
**4. Via file_id:**
```bash
FILE_ID="$(curl -sS -X POST http://localhost:8321/v1/files \
-F "file=@/path/to/sample.pdf" -F "purpose=assistants" | jq -r .id)"
curl -sS -X POST http://localhost:8321/v1alpha/file-processors/process \
-F "file_id=${FILE_ID}" | jq
```
Expected: chunks response with `metadata.processor = "pypdf"` and
`file_id` in chunk metadata.
---------
Signed-off-by: roburishabh <roburishabh@outlook.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Charlie Doern <cdoern@redhat.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Francisco Javier Arceo <arceofrancisco@gmail.com>1 parent 8d9ef64 commit 5d63477
144 files changed
Lines changed: 157208 additions & 38578 deletions
File tree
- .github/workflows
- docs/docs/providers/file_processors
- src/llama_stack
- providers
- inline
- file_processor/pypdf
- vector_io/faiss
- remote/vector_io/weaviate
- utils/memory
- testing
- tests
- integration
- common/recordings
- file_processors
- responses/recordings
- vector_io/recordings
- unit
- distribution
- providers/utils/memory
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 31 | | |
38 | 32 | | |
39 | 33 | | |
| |||
Lines changed: 73 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | | - | |
| 49 | + | |
48 | 50 | | |
49 | | - | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | | - | |
60 | 62 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 65 | | |
73 | 66 | | |
74 | 67 | | |
75 | | - | |
76 | 68 | | |
77 | 69 | | |
78 | 70 | | |
79 | 71 | | |
80 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
87 | | - | |
88 | 100 | | |
89 | 101 | | |
90 | | - | |
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
94 | | - | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 115 | + | |
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | | - | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | | - | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
130 | 168 | | |
131 | 169 | | |
132 | 170 | | |
| |||
140 | 178 | | |
141 | 179 | | |
142 | 180 | | |
143 | | - | |
144 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
145 | 184 | | |
146 | 185 | | |
147 | 186 | | |
| |||
209 | 248 | | |
210 | 249 | | |
211 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
212 | 254 | | |
213 | 255 | | |
214 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
0 commit comments