kennethzychew commited on
Commit
e44ba24
·
1 Parent(s): 8be0822

phase 6: curate Space requirements + fix src import (T11)

Browse files

Replace the uv-export requirements.txt (it pinned gradio/huggingface_hub, which
Spaces preinstall and manage, and pulled the full eval/batch dep set via -e .)
with a demo-only list: docling, google-genai, pydantic, pydantic-settings. Put
src/ on sys.path in app.py so doc_agent imports on the Space without installing
the package. Add short_description to the README front-matter.

Per the huggingface-spaces skill: never pin gradio/huggingface_hub in a Space.

Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +10 -3
  3. requirements.txt +12 -556
README.md CHANGED
@@ -1,5 +1,6 @@
1
  ---
2
  title: Document Extraction Agent
 
3
  colorFrom: indigo
4
  colorTo: blue
5
  sdk: gradio
 
1
  ---
2
  title: Document Extraction Agent
3
+ short_description: Validate and auto-accept or review invoice/receipt fields
4
  colorFrom: indigo
5
  colorTo: blue
6
  sdk: gradio
app.py CHANGED
@@ -1,13 +1,20 @@
1
  """Hugging Face Space entry point.
2
 
3
  A thin launcher for the Gradio demo. All UI and pipeline logic lives in
4
- ``doc_agent.web.app``; this file only builds and launches it so the Space's
5
- Gradio SDK has an ``app.py`` at the repo root to run. Configuration and secrets
 
6
  (GEMINI_API_KEY, EXTRACTION_BACKEND, IMAGE_STRATEGY, GEMINI_MODEL) are read from
7
  the environment -- set them as Space repository secrets, never in a file.
8
  """
9
 
10
- from doc_agent.web.app import build_demo
 
 
 
 
 
 
11
 
12
  demo = build_demo()
13
 
 
1
  """Hugging Face Space entry point.
2
 
3
  A thin launcher for the Gradio demo. All UI and pipeline logic lives in
4
+ ``doc_agent.web.app``; this file only makes the ``src/`` package importable on
5
+ the Space (which runs this file from the repo root without pip-installing the
6
+ package) and then builds and launches the demo. Configuration and secrets
7
  (GEMINI_API_KEY, EXTRACTION_BACKEND, IMAGE_STRATEGY, GEMINI_MODEL) are read from
8
  the environment -- set them as Space repository secrets, never in a file.
9
  """
10
 
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ # src-layout: make `doc_agent` importable without installing the package.
15
+ sys.path.insert(0, str(Path(__file__).parent / "src"))
16
+
17
+ from doc_agent.web.app import build_demo # noqa: E402 (import after path setup)
18
 
19
  demo = build_demo()
20
 
requirements.txt CHANGED
@@ -1,556 +1,12 @@
1
- # This file was autogenerated by uv via the following command:
2
- # uv export --no-hashes --no-dev -o requirements.txt
3
- -e .
4
- accelerate==1.14.0
5
- # via
6
- # docling-ibm-models
7
- # docling-slim
8
- aiohappyeyeballs==2.6.2
9
- # via aiohttp
10
- aiohttp==3.14.1
11
- # via fsspec
12
- aiosignal==1.4.0
13
- # via aiohttp
14
- annotated-doc==0.0.4
15
- # via
16
- # fastapi
17
- # typer
18
- annotated-types==0.7.0
19
- # via pydantic
20
- antlr4-python3-runtime==4.9.3
21
- # via omegaconf
22
- anyio==4.14.1
23
- # via
24
- # google-genai
25
- # gradio
26
- # httpx
27
- # starlette
28
- attrs==26.1.0
29
- # via
30
- # aiohttp
31
- # jsonlines
32
- # jsonschema
33
- # referencing
34
- audioop-lts==0.2.2 ; python_full_version >= '3.13'
35
- # via gradio
36
- beautifulsoup4==4.15.0
37
- # via docling-slim
38
- brotli==1.2.0
39
- # via gradio
40
- certifi==2026.6.17
41
- # via
42
- # docling-slim
43
- # httpcore
44
- # httpx
45
- # requests
46
- cffi==2.0.0 ; platform_python_implementation != 'PyPy'
47
- # via cryptography
48
- charset-normalizer==3.4.7
49
- # via requests
50
- click==8.4.2
51
- # via
52
- # huggingface-hub
53
- # typer
54
- # uvicorn
55
- colorama==0.4.6 ; sys_platform == 'win32'
56
- # via
57
- # click
58
- # colorlog
59
- # tqdm
60
- colorlog==6.10.1
61
- # via rapidocr
62
- cryptography==49.0.0
63
- # via google-auth
64
- cuda-bindings==13.3.1 ; sys_platform == 'linux'
65
- # via torch
66
- cuda-pathfinder==1.5.6 ; sys_platform == 'linux'
67
- # via cuda-bindings
68
- cuda-toolkit==13.0.2 ; sys_platform == 'linux'
69
- # via torch
70
- datasets==5.0.0
71
- # via doc-agent
72
- defusedxml==0.7.1
73
- # via
74
- # docling-core
75
- # docling-slim
76
- dill==0.4.1
77
- # via
78
- # datasets
79
- # multiprocess
80
- distro==1.9.0
81
- # via google-genai
82
- doclang==0.7.0
83
- # via docling-core
84
- docling==2.107.0
85
- # via doc-agent
86
- docling-core==2.85.0
87
- # via
88
- # docling-ibm-models
89
- # docling-parse
90
- # docling-slim
91
- docling-ibm-models==3.13.3
92
- # via docling-slim
93
- docling-parse==7.2.0
94
- # via docling-slim
95
- docling-slim==2.107.0
96
- # via docling
97
- et-xmlfile==2.0.0
98
- # via openpyxl
99
- faker==40.25.0
100
- # via polyfactory
101
- fastapi==0.138.2
102
- # via gradio
103
- filelock==3.29.4
104
- # via
105
- # datasets
106
- # huggingface-hub
107
- # torch
108
- filetype==1.2.0
109
- # via docling-slim
110
- frozenlist==1.8.0
111
- # via
112
- # aiohttp
113
- # aiosignal
114
- fsspec==2026.4.0
115
- # via
116
- # datasets
117
- # gradio-client
118
- # huggingface-hub
119
- # torch
120
- google-auth==2.55.1
121
- # via google-genai
122
- google-genai==2.10.0
123
- # via doc-agent
124
- gradio==6.19.0
125
- # via doc-agent
126
- gradio-client==2.5.0
127
- # via
128
- # gradio
129
- # hf-gradio
130
- groovy==0.1.2
131
- # via gradio
132
- h11==0.16.0
133
- # via
134
- # httpcore
135
- # uvicorn
136
- hf-gradio==0.4.1
137
- # via gradio
138
- hf-xet==1.5.1 ; platform_machine == 'AMD64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'
139
- # via huggingface-hub
140
- httpcore==1.0.9
141
- # via httpx
142
- httpx==0.28.1
143
- # via
144
- # datasets
145
- # docling-slim
146
- # google-genai
147
- # gradio
148
- # gradio-client
149
- # huggingface-hub
150
- # safehttpx
151
- huggingface-hub==1.21.0
152
- # via
153
- # accelerate
154
- # datasets
155
- # docling-ibm-models
156
- # docling-slim
157
- # gradio
158
- # gradio-client
159
- # tokenizers
160
- # transformers
161
- idna==3.18
162
- # via
163
- # anyio
164
- # httpx
165
- # requests
166
- # yarl
167
- jinja2==3.1.6
168
- # via
169
- # gradio
170
- # torch
171
- jsonlines==4.0.0
172
- # via docling-ibm-models
173
- jsonref==1.1.0
174
- # via docling-core
175
- jsonschema==4.26.0
176
- # via docling-core
177
- jsonschema-specifications==2025.9.1
178
- # via jsonschema
179
- latex2mathml==3.81.0
180
- # via docling-core
181
- lxml==6.1.1
182
- # via
183
- # doclang
184
- # docling-slim
185
- # python-docx
186
- # python-pptx
187
- mail-parser==4.4.0
188
- # via docling-slim
189
- markdown-it-py==4.2.0
190
- # via rich
191
- marko==2.2.3
192
- # via docling-slim
193
- markupsafe==3.0.3
194
- # via
195
- # gradio
196
- # jinja2
197
- mdurl==0.1.2
198
- # via markdown-it-py
199
- mpire==2.10.2
200
- # via semchunk
201
- mpmath==1.3.0
202
- # via sympy
203
- multidict==6.7.1
204
- # via
205
- # aiohttp
206
- # yarl
207
- multiprocess==0.70.19
208
- # via
209
- # datasets
210
- # mpire
211
- networkx==3.6.1
212
- # via torch
213
- numpy==2.4.6 ; python_full_version < '3.12'
214
- # via
215
- # accelerate
216
- # datasets
217
- # docling-ibm-models
218
- # docling-slim
219
- # gradio
220
- # opencv-python
221
- # pandas
222
- # rapidocr
223
- # safetensors
224
- # scipy
225
- # shapely
226
- # torchvision
227
- # transformers
228
- numpy==2.5.0 ; python_full_version >= '3.12'
229
- # via
230
- # accelerate
231
- # datasets
232
- # docling-ibm-models
233
- # docling-slim
234
- # gradio
235
- # opencv-python
236
- # pandas
237
- # rapidocr
238
- # safetensors
239
- # scipy
240
- # shapely
241
- # torchvision
242
- # transformers
243
- nvidia-cublas==13.1.1.3 ; sys_platform == 'linux'
244
- # via
245
- # nvidia-cudnn-cu13
246
- # nvidia-cusolver
247
- # torch
248
- nvidia-cuda-cupti==13.0.85 ; sys_platform == 'linux'
249
- # via cuda-toolkit
250
- nvidia-cuda-nvrtc==13.0.88 ; sys_platform == 'linux'
251
- # via
252
- # cuda-toolkit
253
- # nvidia-cublas
254
- nvidia-cuda-runtime==13.0.96 ; sys_platform == 'linux'
255
- # via cuda-toolkit
256
- nvidia-cudnn-cu13==9.20.0.48 ; sys_platform == 'linux'
257
- # via torch
258
- nvidia-cufft==12.0.0.61 ; sys_platform == 'linux'
259
- # via cuda-toolkit
260
- nvidia-cufile==1.15.1.6 ; sys_platform == 'linux'
261
- # via cuda-toolkit
262
- nvidia-curand==10.4.0.35 ; sys_platform == 'linux'
263
- # via cuda-toolkit
264
- nvidia-cusolver==12.0.4.66 ; sys_platform == 'linux'
265
- # via cuda-toolkit
266
- nvidia-cusparse==12.6.3.3 ; sys_platform == 'linux'
267
- # via
268
- # cuda-toolkit
269
- # nvidia-cusolver
270
- nvidia-cusparselt-cu13==0.8.1 ; sys_platform == 'linux'
271
- # via torch
272
- nvidia-nccl-cu13==2.29.7 ; sys_platform == 'linux'
273
- # via torch
274
- nvidia-nvjitlink==13.0.88 ; sys_platform == 'linux'
275
- # via
276
- # cuda-toolkit
277
- # nvidia-cufft
278
- # nvidia-cusolver
279
- # nvidia-cusparse
280
- nvidia-nvshmem-cu13==3.4.5 ; sys_platform == 'linux'
281
- # via torch
282
- nvidia-nvtx==13.0.85 ; sys_platform == 'linux'
283
- # via cuda-toolkit
284
- omegaconf==2.3.1
285
- # via rapidocr
286
- opencv-python==4.13.0.92
287
- # via rapidocr
288
- openpyxl==3.1.5
289
- # via docling-slim
290
- orjson==3.11.9
291
- # via gradio
292
- packaging==26.2
293
- # via
294
- # accelerate
295
- # datasets
296
- # gradio
297
- # gradio-client
298
- # huggingface-hub
299
- # transformers
300
- pandas==3.0.3
301
- # via
302
- # datasets
303
- # docling-core
304
- # gradio
305
- pillow==12.2.0
306
- # via
307
- # datasets
308
- # doc-agent
309
- # docling-core
310
- # docling-ibm-models
311
- # docling-parse
312
- # docling-slim
313
- # gradio
314
- # python-pptx
315
- # rapidocr
316
- # torchvision
317
- pluggy==1.6.0
318
- # via docling-slim
319
- polyfactory==3.3.0
320
- # via docling-slim
321
- propcache==0.5.2
322
- # via
323
- # aiohttp
324
- # yarl
325
- psutil==7.2.2
326
- # via accelerate
327
- pyarrow==24.0.0
328
- # via datasets
329
- pyasn1==0.6.3
330
- # via pyasn1-modules
331
- pyasn1-modules==0.4.2
332
- # via google-auth
333
- pyclipper==1.4.0
334
- # via rapidocr
335
- pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy'
336
- # via cffi
337
- pydantic==2.13.4
338
- # via
339
- # doc-agent
340
- # docling-core
341
- # docling-ibm-models
342
- # docling-parse
343
- # docling-slim
344
- # fastapi
345
- # google-genai
346
- # gradio
347
- # pydantic-settings
348
- pydantic-core==2.46.4
349
- # via pydantic
350
- pydantic-settings==2.14.2
351
- # via
352
- # doc-agent
353
- # docling-core
354
- # docling-slim
355
- pydub==0.25.1
356
- # via gradio
357
- pygments==2.20.0
358
- # via
359
- # mpire
360
- # rich
361
- pylatexenc==2.10
362
- # via docling-slim
363
- pypdfium2==5.11.0
364
- # via docling-slim
365
- python-dateutil==2.9.0.post0
366
- # via pandas
367
- python-docx==1.2.0
368
- # via docling-slim
369
- python-dotenv==1.2.2
370
- # via
371
- # docling-slim
372
- # pydantic-settings
373
- python-multipart==0.0.32
374
- # via gradio
375
- python-pptx==1.0.2
376
- # via docling-slim
377
- pytz==2026.2
378
- # via gradio
379
- pywin32==312 ; sys_platform == 'win32'
380
- # via
381
- # docling-parse
382
- # mpire
383
- pyyaml==6.0.3
384
- # via
385
- # accelerate
386
- # datasets
387
- # docling-core
388
- # gradio
389
- # huggingface-hub
390
- # omegaconf
391
- # rapidocr
392
- # transformers
393
- rapidocr==3.9.0
394
- # via docling-slim
395
- referencing==0.37.0
396
- # via
397
- # jsonschema
398
- # jsonschema-specifications
399
- regex==2026.6.28
400
- # via transformers
401
- requests==2.34.2
402
- # via
403
- # datasets
404
- # docling-slim
405
- # google-auth
406
- # google-genai
407
- # rapidocr
408
- rich==15.0.0
409
- # via
410
- # docling-slim
411
- # typer
412
- rpds-py==2026.6.3
413
- # via
414
- # jsonschema
415
- # referencing
416
- rtree==1.4.1
417
- # via
418
- # docling-ibm-models
419
- # docling-slim
420
- safehttpx==0.1.7
421
- # via gradio
422
- safetensors==0.8.0
423
- # via
424
- # accelerate
425
- # docling-ibm-models
426
- # transformers
427
- saxonche==13.0.0
428
- # via doclang
429
- scipy==1.17.1 ; python_full_version < '3.12'
430
- # via docling-slim
431
- scipy==1.18.0 ; python_full_version >= '3.12'
432
- # via docling-slim
433
- semantic-version==2.10.0
434
- # via gradio
435
- semchunk==3.2.5
436
- # via docling-core
437
- setuptools==81.0.0
438
- # via torch
439
- shapely==2.1.2
440
- # via rapidocr
441
- shellingham==1.5.4
442
- # via typer
443
- six==1.17.0
444
- # via
445
- # python-dateutil
446
- # rapidocr
447
- sniffio==1.3.1
448
- # via google-genai
449
- soupsieve==2.8.4
450
- # via beautifulsoup4
451
- starlette==1.3.1
452
- # via
453
- # fastapi
454
- # gradio
455
- sympy==1.14.0
456
- # via torch
457
- tabulate==0.10.0
458
- # via docling-core
459
- tenacity==9.1.4
460
- # via google-genai
461
- tokenizers==0.22.2
462
- # via transformers
463
- tomlkit==0.14.0
464
- # via gradio
465
- torch==2.12.1
466
- # via
467
- # accelerate
468
- # docling-ibm-models
469
- # docling-slim
470
- # safetensors
471
- # torchvision
472
- torchvision==0.27.1
473
- # via
474
- # docling-ibm-models
475
- # docling-slim
476
- tqdm==4.68.3
477
- # via
478
- # datasets
479
- # docling-ibm-models
480
- # docling-slim
481
- # huggingface-hub
482
- # mpire
483
- # rapidocr
484
- # semchunk
485
- # transformers
486
- transformers==5.8.1
487
- # via
488
- # docling-core
489
- # docling-ibm-models
490
- tree-sitter==0.26.0
491
- # via docling-core
492
- tree-sitter-c==0.24.2
493
- # via docling-core
494
- tree-sitter-javascript==0.25.0
495
- # via docling-core
496
- tree-sitter-python==0.25.0
497
- # via docling-core
498
- tree-sitter-typescript==0.23.2
499
- # via docling-core
500
- triton==3.7.1 ; sys_platform == 'linux'
501
- # via torch
502
- typer==0.24.2
503
- # via
504
- # doclang
505
- # docling-core
506
- # docling-slim
507
- # gradio
508
- # hf-gradio
509
- # huggingface-hub
510
- # transformers
511
- typing-extensions==4.15.0
512
- # via
513
- # aiohttp
514
- # aiosignal
515
- # anyio
516
- # beautifulsoup4
517
- # docling-core
518
- # fastapi
519
- # google-genai
520
- # gradio
521
- # gradio-client
522
- # huggingface-hub
523
- # polyfactory
524
- # pydantic
525
- # pydantic-core
526
- # python-docx
527
- # python-pptx
528
- # referencing
529
- # starlette
530
- # torch
531
- # typing-inspection
532
- typing-inspection==0.4.2
533
- # via
534
- # fastapi
535
- # pydantic
536
- # pydantic-settings
537
- tzdata==2026.2 ; sys_platform == 'emscripten' or sys_platform == 'win32'
538
- # via
539
- # faker
540
- # pandas
541
- urllib3==2.7.0
542
- # via requests
543
- uvicorn==0.49.0
544
- # via gradio
545
- watchdog==6.0.0
546
- # via doc-agent
547
- websockets==16.0
548
- # via
549
- # docling-slim
550
- # google-genai
551
- xlsxwriter==3.2.9
552
- # via python-pptx
553
- xxhash==3.8.0
554
- # via datasets
555
- yarl==1.24.2
556
- # via aiohttp
 
1
+ # Hugging Face Space -- web-demo dependencies only.
2
+ #
3
+ # Deliberately curated, not `uv export`: Spaces preinstall and manage `gradio`
4
+ # and `huggingface_hub`, so listing/pinning them causes resolution failures.
5
+ # `datasets` (eval-only), `pillow` (eval-only), and `watchdog` (batch watcher)
6
+ # are not imported by the demo, so they are omitted to keep the build light.
7
+ # `docling` pulls torch for the native-PDF path; the image path uses Gemini
8
+ # vision and needs only google-genai.
9
+ docling>=2.107.0
10
+ google-genai>=2.10.0
11
+ pydantic>=2.13.4
12
+ pydantic-settings>=2.14.2