readanydoc 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. {readanydoc-0.4.2 → readanydoc-0.4.3}/CHANGELOG.md +11 -0
  2. {readanydoc-0.4.2 → readanydoc-0.4.3}/PKG-INFO +1 -1
  3. {readanydoc-0.4.2 → readanydoc-0.4.3}/plugins/readanydoc/.claude-plugin/plugin.json +1 -1
  4. {readanydoc-0.4.2 → readanydoc-0.4.3}/plugins/readanydoc/.mcp.json +1 -1
  5. {readanydoc-0.4.2 → readanydoc-0.4.3}/pyproject.toml +1 -1
  6. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/__init__.py +1 -1
  7. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/cli.py +15 -1
  8. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/library.py +11 -2
  9. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/mcp_server.py +6 -3
  10. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/coded.py +2 -2
  11. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/extract.py +10 -4
  12. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/field_report.py +16 -3
  13. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/reply_schema.py +105 -23
  14. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_required_choices.py +50 -0
  15. {readanydoc-0.4.2 → readanydoc-0.4.3}/.gitignore +0 -0
  16. {readanydoc-0.4.2 → readanydoc-0.4.3}/LICENSE +0 -0
  17. {readanydoc-0.4.2 → readanydoc-0.4.3}/README.md +0 -0
  18. {readanydoc-0.4.2 → readanydoc-0.4.3}/docs/research/README.md +0 -0
  19. {readanydoc-0.4.2 → readanydoc-0.4.3}/examples/showcase/README.md +0 -0
  20. {readanydoc-0.4.2 → readanydoc-0.4.3}/plugins/readanydoc/.claude-plugin/icon.png +0 -0
  21. {readanydoc-0.4.2 → readanydoc-0.4.3}/plugins/readanydoc/README.md +0 -0
  22. {readanydoc-0.4.2 → readanydoc-0.4.3}/plugins/readanydoc/skills/read-documents/SKILL.md +0 -0
  23. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/__init__.py +0 -0
  24. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/__main__.py +0 -0
  25. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/app.py +0 -0
  26. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/config.py +0 -0
  27. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/contracts.py +0 -0
  28. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/errors.py +0 -0
  29. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/inputs.py +0 -0
  30. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/schemas.py +0 -0
  31. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/service.py +0 -0
  32. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/webhooks.py +0 -0
  33. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/api/worker.py +0 -0
  34. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/__init__.py +0 -0
  35. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/catalog.py +0 -0
  36. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/fetch.py +0 -0
  37. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/grade.py +0 -0
  38. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/report.py +0 -0
  39. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/runner.py +0 -0
  40. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/bench/systems.py +0 -0
  41. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/cvsafe.py +0 -0
  42. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/data/model_limits.json +0 -0
  43. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/__init__.py +0 -0
  44. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/common.py +0 -0
  45. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/docx_reader.py +0 -0
  46. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/errors.py +0 -0
  47. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/heic.py +0 -0
  48. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/legacy.py +0 -0
  49. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/msg.py +0 -0
  50. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/pdf.py +0 -0
  51. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/pptx_reader.py +0 -0
  52. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/prepare.py +0 -0
  53. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/sheets.py +0 -0
  54. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/sniff.py +0 -0
  55. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/intake/text.py +0 -0
  56. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/integrations/__init__.py +0 -0
  57. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/integrations/langchain.py +0 -0
  58. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/integrations/llamaindex.py +0 -0
  59. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/layout/__init__.py +0 -0
  60. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/layout/base.py +0 -0
  61. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/layout/cached.py +0 -0
  62. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/layout/claude.py +0 -0
  63. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/layout/onnx.py +0 -0
  64. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/localmodels.py +0 -0
  65. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/model/__init__.py +0 -0
  66. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/model/document.py +0 -0
  67. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/model_limits.py +0 -0
  68. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/modelspec.py +0 -0
  69. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/paths.py +0 -0
  70. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/__init__.py +0 -0
  71. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assemble.py +0 -0
  72. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/__init__.py +0 -0
  73. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/annotations.py +0 -0
  74. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/furniture.py +0 -0
  75. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/headings.py +0 -0
  76. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/paragraphs.py +0 -0
  77. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/assembly/tables.py +0 -0
  78. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/base.py +0 -0
  79. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/__init__.py +0 -0
  80. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/common.py +0 -0
  81. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/complete.py +0 -0
  82. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/flags.py +0 -0
  83. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/gridrepair.py +0 -0
  84. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/htmlgrid.py +0 -0
  85. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/numbers.py +0 -0
  86. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/checks/reread.py +0 -0
  87. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/common.py +0 -0
  88. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/figures/__init__.py +0 -0
  89. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/figures/layout_pictures.py +0 -0
  90. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/figures/locate.py +0 -0
  91. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/__init__.py +0 -0
  92. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/acroform.py +0 -0
  93. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/checkbox.py +0 -0
  94. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/fillable.py +0 -0
  95. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/grid.py +0 -0
  96. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/lines.py +0 -0
  97. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/locate.py +0 -0
  98. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/region.py +0 -0
  99. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/forms/rules.py +0 -0
  100. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/ground.py +0 -0
  101. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/__init__.py +0 -0
  102. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/align.py +0 -0
  103. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/confidence.py +0 -0
  104. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/ocr.py +0 -0
  105. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/sources.py +0 -0
  106. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/tables.py +0 -0
  107. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/grounding/tokens.py +0 -0
  108. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/intake.py +0 -0
  109. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/layout.py +0 -0
  110. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/mdblocks.py +0 -0
  111. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/read.py +0 -0
  112. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/__init__.py +0 -0
  113. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/budget.py +0 -0
  114. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/effort_route.py +0 -0
  115. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/escalate.py +0 -0
  116. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/evidence.py +0 -0
  117. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/form_prefetch.py +0 -0
  118. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/formulas.py +0 -0
  119. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/fusion.py +0 -0
  120. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/handwriting.py +0 -0
  121. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/robust.py +0 -0
  122. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/select.py +0 -0
  123. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/strips.py +0 -0
  124. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/tables.py +0 -0
  125. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/zoom.py +0 -0
  126. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/zoom_gate.py +0 -0
  127. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/zoom_regions.py +0 -0
  128. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/reading/zoom_schedule.py +0 -0
  129. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/__init__.py +0 -0
  130. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/assemble.py +0 -0
  131. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/complete.py +0 -0
  132. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/crops.py +0 -0
  133. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/fields.py +0 -0
  134. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/formevidence.py +0 -0
  135. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/forms.py +0 -0
  136. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/furniture.py +0 -0
  137. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/match.py +0 -0
  138. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/structure.py +0 -0
  139. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/regions/tables.py +0 -0
  140. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/request.py +0 -0
  141. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shape.py +0 -0
  142. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/__init__.py +0 -0
  143. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/agentic.py +0 -0
  144. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/chunking.py +0 -0
  145. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/embed.py +0 -0
  146. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/merge.py +0 -0
  147. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/options.py +0 -0
  148. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/page_range.py +0 -0
  149. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/response.py +0 -0
  150. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/searchable.py +0 -0
  151. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/summarize.py +0 -0
  152. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/shaping/tables.py +0 -0
  153. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/tables/__init__.py +0 -0
  154. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/tables/evidence.py +0 -0
  155. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/tables/hygiene.py +0 -0
  156. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/tables/prefetch.py +0 -0
  157. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/tables/reread.py +0 -0
  158. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/triage.py +0 -0
  159. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/typing/__init__.py +0 -0
  160. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/typing/layout.py +0 -0
  161. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/typing/markup.py +0 -0
  162. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/pipeline/verify.py +0 -0
  163. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/profiles.py +0 -0
  164. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/__init__.py +0 -0
  165. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/anthropic_api.py +0 -0
  166. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/anthropic_batch.py +0 -0
  167. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/base.py +0 -0
  168. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/batch_mode.py +0 -0
  169. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/cached.py +0 -0
  170. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/claude_cli.py +0 -0
  171. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/crop_cache.py +0 -0
  172. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/live_cache.py +0 -0
  173. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/ocr_words.py +0 -0
  174. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/openai_compatible.py +0 -0
  175. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/prompts.py +0 -0
  176. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/sizing.py +0 -0
  177. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/readers/usage.py +0 -0
  178. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/serialize/__init__.py +0 -0
  179. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/serialize/citations.py +0 -0
  180. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/serialize/reducto.py +0 -0
  181. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/star.py +0 -0
  182. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/store/__init__.py +0 -0
  183. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/store/cleanup.py +0 -0
  184. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/store/db.py +0 -0
  185. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/store/files.py +0 -0
  186. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/store/jobs.py +0 -0
  187. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/__init__.py +0 -0
  188. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/classify.py +0 -0
  189. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/common.py +0 -0
  190. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/detect.py +0 -0
  191. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/edit.py +0 -0
  192. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/extract_extras.py +0 -0
  193. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/llm.py +0 -0
  194. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/schema.py +0 -0
  195. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/tasks/split.py +0 -0
  196. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/textlayer.py +0 -0
  197. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/textnorm.py +0 -0
  198. {readanydoc-0.4.2 → readanydoc-0.4.3}/readanydoc/trace.py +0 -0
  199. {readanydoc-0.4.2 → readanydoc-0.4.3}/research/README.md +0 -0
  200. {readanydoc-0.4.2 → readanydoc-0.4.3}/research/benchmarks/README.md +0 -0
  201. {readanydoc-0.4.2 → readanydoc-0.4.3}/results/README.md +0 -0
  202. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/__init__.py +0 -0
  203. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/__init__.py +0 -0
  204. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/conftest.py +0 -0
  205. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/sdk_check.py +0 -0
  206. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_auth.py +0 -0
  207. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_cleanup.py +0 -0
  208. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_config_defaults.py +0 -0
  209. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_contract.py +0 -0
  210. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_e2e.py +0 -0
  211. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_jobs.py +0 -0
  212. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_sdk.py +0 -0
  213. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/api/test_webhooks.py +0 -0
  214. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/assembly/__init__.py +0 -0
  215. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/assembly/evaluate.py +0 -0
  216. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/assembly/synth.py +0 -0
  217. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/assembly/test_assembly.py +0 -0
  218. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/assembly/test_real_documents.py +0 -0
  219. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/checks/__init__.py +0 -0
  220. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/checks/test_checks_stage.py +0 -0
  221. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/checks/test_complete.py +0 -0
  222. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/checks/test_htmlgrid.py +0 -0
  223. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/checks/test_numbers.py +0 -0
  224. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/conftest.py +0 -0
  225. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/cost/__init__.py +0 -0
  226. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/cost/test_r3b_cost.py +0 -0
  227. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/figures/__init__.py +0 -0
  228. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/figures/test_figures.py +0 -0
  229. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/forms/__init__.py +0 -0
  230. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/forms/test_fillable.py +0 -0
  231. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/forms/test_grid.py +0 -0
  232. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/forms/test_lines_crops.py +0 -0
  233. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/forms/test_rules.py +0 -0
  234. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/grounding/__init__.py +0 -0
  235. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/grounding/test_grounding.py +0 -0
  236. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/intake/__init__.py +0 -0
  237. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/intake/test_intake.py +0 -0
  238. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/judge/__init__.py +0 -0
  239. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/judge/test_judge.py +0 -0
  240. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/__init__.py +0 -0
  241. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/test_handwriting_route.py +0 -0
  242. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/test_live_profile.py +0 -0
  243. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/test_reading_pipeline.py +0 -0
  244. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/test_reading_units.py +0 -0
  245. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/reading/test_robustness.py +0 -0
  246. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/regions/__init__.py +0 -0
  247. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/regions/test_fields.py +0 -0
  248. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/regions/test_furniture.py +0 -0
  249. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/regions/test_regions.py +0 -0
  250. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/shaping/__init__.py +0 -0
  251. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/shaping/test_chunking.py +0 -0
  252. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/shaping/test_round2_options.py +0 -0
  253. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/shaping/test_tables.py +0 -0
  254. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tables/__init__.py +0 -0
  255. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tables/test_tables_round2.py +0 -0
  256. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/__init__.py +0 -0
  257. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/conftest.py +0 -0
  258. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/live_notes.md +0 -0
  259. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/live_smoke.py +0 -0
  260. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_edit.py +0 -0
  261. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_extract.py +0 -0
  262. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_extract_extras.py +0 -0
  263. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_extract_robust.py +0 -0
  264. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_llm.py +0 -0
  265. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_reply_schema.py +0 -0
  266. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_review.py +0 -0
  267. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_schema.py +0 -0
  268. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/tasks/test_split_classify.py +0 -0
  269. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_bench.py +0 -0
  270. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_bench_suite.py +0 -0
  271. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_engine_final.py +0 -0
  272. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_integrations.py +0 -0
  273. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_library.py +0 -0
  274. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_localmodels.py +0 -0
  275. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_mcp_server.py +0 -0
  276. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_model.py +0 -0
  277. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_pipeline.py +0 -0
  278. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_readers.py +0 -0
  279. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_robust_fallbacks.py +0 -0
  280. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_serializer.py +0 -0
  281. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_star.py +0 -0
  282. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_ws4_ocr_prep.py +0 -0
  283. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_ws4_speed_batch.py +0 -0
  284. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/test_zoom_vote.py +0 -0
  285. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/typing/__init__.py +0 -0
  286. {readanydoc-0.4.2 → readanydoc-0.4.3}/tests/typing/test_typing.py +0 -0
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.3 (2026-11-19)
4
+
5
+ - `fill_required` (Python, CLI `--fill-required`, MCP, `settings.fill_required`): which required fields always get
6
+ a value. `"choices"` (default, as in 0.4.2): required yes/no and enum fields. `True`: also every required number
7
+ and text field. A list of field paths: the choices and those fields. `False`: none. Forced numbers and text may be
8
+ guesses: with `review`, each one not printed in the document is flagged `filled_because_required`. On a pack of 5
9
+ order forms, `True` scored 98.3% of fields right against 100% for the default (it filled end dates the answer
10
+ key leaves empty).
11
+ - Review: a total row whose label spans the columns ("Monthly recurring | USD 1,500.00") no longer counts as a
12
+ missing list item.
13
+
3
14
  ## 0.4.2 (2026-11-19)
4
15
 
5
16
  From a user's test of 0.4.0 on a pack of 5 order forms (their scorer: 97.9% of fields right). After these fixes,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readanydoc
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API
5
5
  Project-URL: Homepage, https://arpitpatel25.github.io/ReadAnyDoc/
6
6
  Project-URL: Repository, https://github.com/arpitpatel25/ReadAnyDoc
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "readanydoc",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Parse PDFs, scans, photos and Office files into Markdown, and extract typed fields with a citation for every value. Open-source alternative to Reducto, on your own Anthropic key.",
5
5
  "author": {
6
6
  "name": "Unmute"
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "readanydoc": {
4
4
  "command": "uvx",
5
- "args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@71184aae2561ba4da675b20c216c0844b7c5d12f", "readanydoc", "mcp"]
5
+ "args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@b734ee33eee51402d43eec7ce92549b99d766e03", "readanydoc", "mcp"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readanydoc"
3
- version = "0.4.2"
3
+ version = "0.4.3"
4
4
  description = "Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "readanydoc contributors" }]
@@ -3,7 +3,7 @@
3
3
  Use it as a library (``readanydoc.parse``, ``readanydoc.extract``) or run the server (``readanydoc serve``).
4
4
  """
5
5
 
6
- __version__ = "0.4.2"
6
+ __version__ = "0.4.3"
7
7
 
8
8
  from .library import (Block, BoundingBox, Citation, ExtractResult, ParseResult, Usage, # noqa: E402
9
9
  extract, parse)
@@ -69,6 +69,16 @@ def _parse_profile(args: argparse.Namespace) -> int:
69
69
  return 0
70
70
 
71
71
 
72
+ def _fill(v):
73
+ if v is None:
74
+ return "choices"
75
+ if v == []:
76
+ return True
77
+ if v == ["none"]:
78
+ return False
79
+ return v
80
+
81
+
72
82
  def _extract(args: argparse.Namespace) -> int:
73
83
  from .library import extract
74
84
  with open(args.schema) as f:
@@ -81,7 +91,7 @@ def _extract(args: argparse.Namespace) -> int:
81
91
  alts = True if alts == [] else (alts or False)
82
92
  result = extract(args.input, schema, instructions=instructions, citations=not args.no_citations,
83
93
  extract_model=args.extract_model, review=args.review, alternatives=alts,
84
- derived_values=not args.printed_only, **_common(args))
94
+ derived_values=not args.printed_only, fill_required=_fill(args.fill_required), **_common(args))
85
95
  _warn(result.warnings)
86
96
  out = {"data": result.data, "citations": {k: [c.model_dump() for c in v] for k, v in result.citations.items()},
87
97
  **({"review": result.review} if args.review else {}),
@@ -206,6 +216,10 @@ def main(argv: list[str] | None = None) -> int:
206
216
  x.add_argument("--alternatives", nargs="*", metavar="FIELD",
207
217
  help="also return other values the document gives for a field (a special term, an amendment); "
208
218
  "for every field, or only the fields named")
219
+ x.add_argument("--fill-required", nargs="*", metavar="FIELD",
220
+ help="always give a value to required fields: alone, every required field (numbers and text "
221
+ "too: the model may guess, and each guess is flagged in --review); with FIELDs, only those; "
222
+ "'none' for no field. Default: required yes/no and enum fields only")
209
223
  x.add_argument("--printed-only", action="store_true",
210
224
  help="only values printed in the document: never one worked out or assumed")
211
225
  _model_args(x)
@@ -150,7 +150,8 @@ def extract(source: Source, schema: Union[dict[str, Any], type[BaseModel]], *, i
150
150
  pages: Optional[list[int]] = None, filename: Optional[str] = None,
151
151
  settings: Optional[dict[str, Any]] = None, timeout: Optional[float] = None, review: bool = False,
152
152
  alternatives: Union[bool, list[str]] = False, derived_values: bool = True,
153
- part_tokens: Optional[int] = None, parse: bool = True) -> ExtractResult:
153
+ part_tokens: Optional[int] = None, parse: bool = True,
154
+ fill_required: Union[bool, str, list[str]] = "choices") -> ExtractResult:
154
155
  """Extract the fields of ``schema`` (a JSON Schema dict or a pydantic model class) from a document.
155
156
 
156
157
  ``instructions`` is the system prompt for the extraction model. ``array_extract`` processes long documents in
@@ -164,6 +165,13 @@ def extract(source: Source, schema: Union[dict[str, Any], type[BaseModel]], *, i
164
165
  extraction model): the pages are not parsed first; the model reads the file itself (a PDF, or the pages of an
165
166
  image), and citations are found by code in the PDF's own words or, for scans and images, in local OCR words.
166
167
  About half the cost and 2.5 times faster on a 43-page report, but less accurate: see docs/decisions.md.
168
+
169
+ ``fill_required``: which required fields always get a value. ``"choices"`` (default): required yes/no and enum
170
+ fields (the document's terms decide them; "Net 30" means last day of month = false). ``True``: also every
171
+ required number and text field. A list of field paths (``["customer.tax_id", "items[].amount"]``): the choices
172
+ and these fields. ``False``: none, a value the document does not give stays null. Forcing numbers or text makes
173
+ the model guess when the document does not give the value: each such value not printed in the document is
174
+ flagged ``filled_because_required`` in ``review``. Not forced: a field stays null and is listed in ``warnings``.
167
175
  """
168
176
  from .tasks import extract as extract_task
169
177
  from .tasks.llm import get_llm
@@ -186,7 +194,8 @@ def extract(source: Source, schema: Union[dict[str, Any], type[BaseModel]], *, i
186
194
  "settings": {**(settings or {}), "citations": {"enabled": citations}, "array_extract": array_extract,
187
195
  **({"review": True} if review else {}), **({"alternatives": alternatives} if alternatives else {}),
188
196
  **({} if derived_values else {"derived_values": False}),
189
- **({"part_tokens": part_tokens} if part_tokens else {})},
197
+ **({"part_tokens": part_tokens} if part_tokens else {}),
198
+ **({} if fill_required == "choices" else {"fill_required": fill_required})},
190
199
  }
191
200
  llm = get_llm(make_spec(extract_model or model, extract_effort or effort, extract_options))
192
201
  if not parse and type(llm).__name__ != "AnthropicAPILLM":
@@ -47,7 +47,7 @@ def parse_document(path: str, mode: str = "engine", pages: Optional[list[int]] =
47
47
  def extract_fields(path: str, schema: dict[str, Any], instructions: Optional[str] = None,
48
48
  array_extract: bool = False, mode: str = "engine", review: bool = True,
49
49
  alternatives: bool = False, part_tokens: Optional[int] = None,
50
- parse_first: bool = True) -> dict[str, Any]:
50
+ parse_first: bool = True, fill_required: Any = "choices") -> dict[str, Any]:
51
51
  """Extract structured values from a local document into a JSON Schema, with citations.
52
52
 
53
53
  schema: a JSON Schema object (type "object" with properties). instructions: optional guidance for the
@@ -55,13 +55,16 @@ def extract_fields(path: str, schema: dict[str, Any], instructions: Optional[str
55
55
  check (found by code, no extra cost). alternatives: also return other values the document gives for a field
56
56
  (a special term or an amendment that changes a price). part_tokens: largest document part per call, in tokens
57
57
  (default 30,000). parse_first: false to skip parsing (the model reads the file itself: about half the cost and
58
- faster, less accurate, fewer citations).
58
+ faster, less accurate, fewer citations). fill_required: which required fields always get a value: "choices"
59
+ (default, yes/no and enum fields), true (numbers and text too: the model may guess, each guess is flagged in
60
+ to_check as filled_because_required), a list of field paths, or false (nothing forced).
59
61
  """
60
62
  import readanydoc
61
63
  if isinstance(schema, str):
62
64
  schema = json.loads(schema)
63
65
  res = readanydoc.extract(_path(path), schema, instructions=instructions, array_extract=array_extract, mode=mode,
64
- review=review, alternatives=alternatives, part_tokens=part_tokens, parse=parse_first)
66
+ review=review, alternatives=alternatives, part_tokens=part_tokens, parse=parse_first,
67
+ fill_required=fill_required)
65
68
  data = res.data.model_dump() if hasattr(res.data, "model_dump") else res.data
66
69
  cites = {k: [c.model_dump(exclude_none=True) for c in v] for k, v in res.citations.items()}
67
70
  return {"data": data, "citations": cites, "warnings": res.warnings,
@@ -30,8 +30,8 @@ NOTE = ('Answer as {"values": [...]} with one entry per value: "code" is the fie
30
30
  "column, section or page (a unit, a scale such as \"in thousands\", a currency, a date or period in a "
31
31
  "heading) applies to every item it covers: write it on each of those items. Leave out only a field the "
32
32
  "document gives no value for and does not make clear; never write a guess. A field marked \"always answer\" is "
33
- "required in every list item or section you write: never leave it out there, write the choice the "
34
- "document\'s terms mean (it never makes you write an item or section the document does not have). A value the document gives in "
33
+ "required in every list item or section you write: never leave it out there; write the choice or value "
34
+ "the document\'s terms mean (it never makes you write an item or section the document does not have). A value the document gives in "
35
35
  "another form is not a guess: write it in the form the field asks for (a country name as its code). "
36
36
  'Write numbers as plain digits ("4200.50", "-1200") and dates in the format the field asks for. '
37
37
  'Copy names, titles and labels exactly as printed, every word of them, even when part of a name looks like '
@@ -756,6 +756,8 @@ def carry_hint(prev: Any) -> str:
756
756
  # ---------------------------------------------------------------- the extractor
757
757
 
758
758
  class _Extractor:
759
+ fill: Any = "choices" # the fill_required policy (reply_schema.fill_policy)
760
+
759
761
  def __init__(self, view: DocView, pages: list[PageRef], user_schema: dict, system_prompt: str,
760
762
  llm: LLM, opts: dict, track: bool, include_images: bool):
761
763
  if getattr(llm, "prompt_cache", False) and not opts.get("max_tokens_set"):
@@ -868,7 +870,7 @@ class _Extractor:
868
870
  plain = copy.deepcopy(plain)
869
871
  RS.take_blocks(plain)
870
872
  plain.pop(RS.ALT_FIELD, None)
871
- plain = RS.from_reply(plain, self.prompt_schema)
873
+ plain = RS.from_reply(plain, self.prompt_schema, getattr(self, "fill", "choices"))
872
874
  check = S.enforced(self.prompt_schema)
873
875
  _, moved, stray = S.relocate(plain, check)
874
876
  if moved or stray or S.find_errors(S.conform(plain, check), check):
@@ -1089,7 +1091,7 @@ class _Extractor:
1089
1091
  alts += [x for x in a if isinstance(x, dict) and str(x.get("value", "")).strip()]
1090
1092
  merged = RS.merge(merged, v)
1091
1093
  hints = RS.take_marks(merged)
1092
- value = S.conform(RS.from_reply(merged, user), strict)
1094
+ value = S.conform(RS.from_reply(merged, user, self.fill), strict)
1093
1095
  if value is None and S.is_object(strict):
1094
1096
  value = S.empty_instance(strict)
1095
1097
  return value, hints, alts
@@ -1199,7 +1201,7 @@ class _Extractor:
1199
1201
  merged = RS.merge(merged, v)
1200
1202
  alts += a
1201
1203
  hints = RS.take_marks(merged)
1202
- value = S.conform(RS.from_reply(merged, user), strict)
1204
+ value = S.conform(RS.from_reply(merged, user, self.fill), strict)
1203
1205
  if value is None and S.is_object(strict):
1204
1206
  value = S.empty_instance(strict)
1205
1207
  errors = S.find_errors(value, strict)
@@ -1851,10 +1853,12 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
1851
1853
  review_on = bool(settings.get("review")) # code-only checks on the answer, returned under "review"
1852
1854
  alt_cfg = settings.get("alternatives") # other values the document gives for a field (true or a list of paths)
1853
1855
  derived_ok = settings.get("derived_values", True) is not False
1856
+ fill = RS.fill_policy(settings.get("fill_required")) # which required fields must be answered (reply_schema)
1854
1857
  # The model writes only the user's fields. Per-value source labels are asked for only by deep_extract,
1855
1858
  # whose checks need them; citations are found by code (code_citations).
1856
1859
  track = deep
1857
1860
  ex = _Extractor(view, pages, user_schema, system_prompt, llm, opts, track, bool(settings.get("include_images")))
1861
+ ex.fill = fill
1858
1862
  ex.direct = dict(opts.get("direct") or {})
1859
1863
  ex.pdf_path = "direct" if (ex.direct.get("pdf") or ex.direct.get("images")) else None
1860
1864
  from . import field_report as FR
@@ -1864,7 +1868,7 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
1864
1868
  is_obj = S.is_object(ex.strict)
1865
1869
  use_reply = is_obj and not deep and not use_loop
1866
1870
  if use_reply: # structured outputs for any schema size (reply_schema): the model answers in this shape
1867
- reply = RS.to_reply(ex.prompt_schema)
1871
+ reply = RS.to_reply(ex.prompt_schema, policy=fill)
1868
1872
  if citations_on:
1869
1873
  reply = RS.add_blocks(reply, blocks=not ex.pdf_path) # the PDF has no block labels to name
1870
1874
  ex.labels = not ex.pdf_path
@@ -1900,6 +1904,7 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
1900
1904
  "fields_per_group": int(opts.get("coded_group_leaves", 40)), "max_output_tokens": ex.opts.get("max_tokens"),
1901
1905
  "citations": citations_on, "deep_extract": deep, "array_extract": bool(settings.get("array_extract")),
1902
1906
  "review": review_on, "alternatives": bool(alt_cfg), "derived_values": derived_ok,
1907
+ "fill_required": sorted(fill) if isinstance(fill, set) else fill,
1903
1908
  "include_images": bool(settings.get("include_images")), "page_range": settings.get("page_range"),
1904
1909
  "relevance_filter": bool(settings.get("relevance_filter")), "pages": len(pages),
1905
1910
  "one_stage": bool(ex.pdf_path), # the model read the PDF itself; no parsing stage
@@ -2083,6 +2088,7 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
2083
2088
  extra_out["alternatives"] = found
2084
2089
  if review_on:
2085
2090
  extra_out["review"] = FR.review(value, ex.strict, cites, ex, conflicts=conflicts, unreadable=set(still),
2091
+ filled=RS.forced_paths(ex.prompt_schema, fill) if use_reply else set(),
2086
2092
  pages=all_pages)
2087
2093
 
2088
2094
  view.docs[0].usage.append({"task": "extract", **sum_usage(ex.results)})
@@ -7,6 +7,8 @@ Each check names a field and a reason a reader should look at it:
7
7
  and month order, a negative in parentheses, "amounts in thousands", a percentage returned as a fraction);
8
8
  - ``struck_through``: every place the value is printed is crossed out; ``void_page``: its page is stamped VOID;
9
9
  - ``segments_disagree``: two parts of a long document gave different values;
10
+ - ``filled_because_required``: a number or text field filled because ``fill_required`` asks for it, and not
11
+ printed in the document as returned: it may be a guess;
10
12
  - ``list_may_be_incomplete``: a list has fewer items than the rows with an amount in the table it was read from;
11
13
  - ``unreadable``: the model's reply for the field could not be read.
12
14
 
@@ -203,7 +205,11 @@ def amount_rows(content: str) -> int:
203
205
  c = content or ""
204
206
  if re.search(r"<tr\b", c, re.I):
205
207
  n = 0
206
- for row in re.findall(r"<tr\b[^>]*>(.*?)</tr>", c, re.I | re.S):
208
+ rows = re.findall(r"<tr\b[^>]*>(.*?)</tr>", c, re.I | re.S)
209
+ width = max((len(re.findall(r"<t[dh]\b", r, re.I)) for r in rows), default=0)
210
+ for row in rows:
211
+ if len(re.findall(r"<t[dh]\b", row, re.I)) < width: # a label spanning the columns: a total row
212
+ continue
207
213
  if re.search(r"<th\b", row, re.I):
208
214
  continue
209
215
  cells = [" ".join(re.sub(r"<[^>]+>", " ", x).split()) for x in re.findall(r"<td\b[^>]*>(.*?)</td>", row, re.I | re.S)]
@@ -219,6 +225,10 @@ def amount_rows(content: str) -> int:
219
225
  return sum(1 for ln in body if not _SUMMARY_ROW.search(ln) and _AMOUNT.search(ln))
220
226
 
221
227
 
228
+ def _norm(path: tuple) -> str:
229
+ return ".".join(str(p) for p in path if isinstance(p, str))
230
+
231
+
222
232
  def _category(leaf: Any) -> bool:
223
233
  """An enum or const field: a category the model picks (a pricing model, a billing cadence code), which is not
224
234
  printed on the page as such, so "not printed" says nothing about it."""
@@ -229,7 +239,7 @@ def _category(leaf: Any) -> bool:
229
239
 
230
240
 
231
241
  def review(value: Any, schema: Any, cites: dict, ex: Any, *, conflicts: list, unreadable: set,
232
- pages: list[PageRef]) -> list[dict]:
242
+ pages: list[PageRef], filled: Any = ()) -> list[dict]:
233
243
  """[{"field", "flag", "detail"}] for the values a reader should check (see the module docstring)."""
234
244
  out: list[dict] = []
235
245
  void = void_pages(pages)
@@ -244,7 +254,10 @@ def review(value: Any, schema: Any, cites: dict, ex: Any, *, conflicts: list, un
244
254
  continue
245
255
  key = S.path_str(path)
246
256
  good = [c for c in cites.get(path) or [] if c.get("confidence") == "high"]
247
- if not good and not _category(_leaf):
257
+ if not good and _norm(path) in filled:
258
+ add(key, "filled_because_required", "not printed in the document as returned; filled because the "
259
+ "schema requires it (fill_required): it may be a guess")
260
+ elif not good and not _category(_leaf):
248
261
  add(key, "not_found_on_page", "not printed in the document as returned: worked out, converted or assumed")
249
262
  for c in good[:1]:
250
263
  for flag, note in format_flags(v, c.get("content"), (c.get("parentBlock") or {}).get("content", "")):
@@ -66,46 +66,99 @@ def _live(node: dict) -> list:
66
66
  return [b for b in br if S.types_of(b) != {"null"} and b != {"type": "null"}]
67
67
 
68
68
 
69
- def to_reply(schema: Any, must: bool = True) -> Any:
69
+ FILL_HINT = ("always answer: required by the schema; when the document does not give it, write your best value "
70
+ "from the document")
71
+
72
+
73
+ def fill_policy(value: Any) -> Any:
74
+ """The ``fill_required`` setting as used inside: "choices" (default), True, False, or a set of field paths
75
+ (names joined by dots, list brackets dropped: "contract.line_items.prices.price.unit_amount")."""
76
+ if value is None or value == "choices":
77
+ return "choices"
78
+ if isinstance(value, bool):
79
+ return value
80
+ if isinstance(value, str):
81
+ value = [value]
82
+ return {_norm_path(str(v)) for v in value if str(v).strip()}
83
+
84
+
85
+ def _norm_path(p: Any) -> str:
86
+ if isinstance(p, tuple):
87
+ return ".".join(str(x) for x in p if isinstance(x, str) and x != "[]")
88
+ return ".".join(x for x in re.sub(r"\[[^\]]*\]", "", p).split(".") if x)
89
+
90
+
91
+ def to_reply(schema: Any, must: bool = True, policy: Any = "choices", path: tuple = (),
92
+ _forced_leaf: bool = False) -> Any:
70
93
  """The structured-output version of a resolved schema (see the module docstring).
71
94
 
72
- ``must``: the user's schema requires this value and does not allow null, and every object above it is always
73
- present (required, not nullable). A yes/no, enum or const field like that gets no "" choice: the API makes the
74
- model answer it, so the output never breaks the user's required type. Other required fields keep "" (no
75
- number or text is ever made up); one that comes back empty is reported (``required_warnings``)."""
95
+ ``must``: this object is always present (required and not nullable all the way up). ``policy``: which fields
96
+ must be answered (``fill_policy``; see ``_forced``). A forced yes/no, enum or const gets no "" choice, so the
97
+ API makes the model answer it; a forced number or text keeps "" (it cannot be forced by the grammar without
98
+ allowing made-up text) and is asked for in its description instead."""
76
99
  if not isinstance(schema, dict):
77
100
  return {"type": "string"}
78
101
  must = must and not _allows_null(schema)
79
102
  live = _live(schema)
80
103
  if len(live) == 1 and live[0] is not schema:
81
104
  merged = {**{k: v for k, v in schema.items() if k not in ("anyOf", "oneOf")}, **live[0]}
82
- return to_reply(merged, must)
105
+ return to_reply(merged, must, policy, path, _forced_leaf)
83
106
  if len(live) > 1:
84
- return {"anyOf": [to_reply(b, False) for b in live], **_desc(schema)}
107
+ return {"anyOf": [to_reply(b, False, policy, path) for b in live], **_desc(schema)}
85
108
  ts = S.types_of(schema) - {"null"}
86
- empty = [] if must else [""]
109
+ empty = [] if _forced_leaf else [""]
87
110
  if "const" in schema:
88
111
  return {"type": "string", "enum": [str(schema["const"])] + empty, **_desc(schema)}
89
112
  if S.is_object(schema) or ("object" in ts and "properties" in schema):
90
- req, forced = set(schema.get("required") or []), _forced(schema, must)
91
- props = {k: to_reply(v, k in forced or (must and k in req)) for k, v in (schema.get("properties") or {}).items()}
113
+ req, forced = set(schema.get("required") or []), _forced(schema, must, policy, path)
114
+ props = {k: to_reply(v, must and k in req, policy, path + (k,), k in forced)
115
+ for k, v in (schema.get("properties") or {}).items()}
92
116
  return {"type": "object", "properties": props, "required": list(props), "additionalProperties": False,
93
117
  **_desc(schema)}
94
118
  if "array" in ts or "items" in schema:
95
- return {"type": "array", "items": to_reply(schema.get("items") or {"type": "string"}), **_desc(schema)}
119
+ return {"type": "array", "items": to_reply(schema.get("items") or {"type": "string"}, True, policy, path),
120
+ **_desc(schema)}
96
121
  enum = schema.get("enum")
97
122
  if isinstance(enum, list):
98
123
  vals = [str(v).lower() if isinstance(v, bool) else str(v) for v in enum if v is not None]
99
124
  return {"type": "string", "enum": list(dict.fromkeys(vals + empty)) or [""], **_desc(schema)}
100
125
  if ts == {"boolean"}:
101
126
  return {"type": "string", "enum": ["true", "false"] + empty, **_desc(schema)}
127
+ hint = FILL_HINT if _forced_leaf else ""
102
128
  if ts & {"number", "integer"} and "string" not in ts:
103
- return {"type": "string", **_desc(schema, "a number")}
104
- return {"type": "string", **_desc(schema)}
129
+ return {"type": "string", **_desc(schema, "; ".join(x for x in ["a number", hint] if x))}
130
+ return {"type": "string", **_desc(schema, hint)}
105
131
 
106
132
 
107
- def from_reply(value: Any, schema: Any) -> Any:
108
- """The answer in the user's types: "" -> null, number and yes/no text converted, enum spelling matched."""
133
+ def forced_paths(schema: Any, policy: Any = "choices") -> set:
134
+ """Normalised paths (``_norm_path``) of the number and text fields that ``policy`` forces: the values a
135
+ review marks as filled because the schema requires them, when the document does not print them."""
136
+ out: set = set()
137
+
138
+ def go(node: Any, must: bool, path: tuple) -> None:
139
+ if not isinstance(node, dict):
140
+ return
141
+ must = must and not _allows_null(node)
142
+ live = _live(node)
143
+ n = live[0] if len(live) == 1 else node
144
+ if not isinstance(n, dict):
145
+ return
146
+ if S.is_object(n):
147
+ req, forced = set(n.get("required") or []), _forced(n, must, policy, path)
148
+ for k, v in (n.get("properties") or {}).items():
149
+ if k in forced and not _choice(v):
150
+ out.add(_norm_path(path + (k,)))
151
+ go(v, must and k in req, path + (k,))
152
+ elif S.is_array(n):
153
+ go(n.get("items") or {}, True, path)
154
+
155
+ go(schema, True, ())
156
+ return out
157
+
158
+
159
+ def from_reply(value: Any, schema: Any, policy: Any = "choices", path: tuple = ()) -> Any:
160
+ """The answer in the user's types: "" -> null, number and yes/no text converted, enum spelling matched.
161
+ ``policy``: the ``fill_required`` setting the reply schema was built with (``fill_policy``)."""
109
162
  if not isinstance(schema, dict):
110
163
  return value
111
164
  nullable = _allows_null(schema)
@@ -116,11 +169,11 @@ def from_reply(value: Any, schema: Any) -> Any:
116
169
  if S.is_object(schema):
117
170
  if not isinstance(value, dict):
118
171
  return None if value in ("", None) else value
119
- out = {k: from_reply(value.get(k), sub) for k, sub in schema["properties"].items()} | \
172
+ out = {k: from_reply(value.get(k), sub, policy, path + (k,)) for k, sub in schema["properties"].items()} | \
120
173
  {k: v for k, v in value.items() if k not in schema["properties"]}
121
174
  # an optional object the document does not have comes back as null, as the user's schema allows; its
122
175
  # yes/no and enum fields that had to be answered (``_forced``) do not count as something found
123
- forced = _forced(schema, False)
176
+ forced = _forced(schema, False, policy, path)
124
177
  return None if nullable and _blank({k: v for k, v in out.items() if k not in forced}) else out
125
178
  if S.is_array(schema):
126
179
  if value in ("", None):
@@ -128,9 +181,9 @@ def from_reply(value: Any, schema: Any) -> Any:
128
181
  if not isinstance(value, list):
129
182
  return value
130
183
  items = schema.get("items") or {}
131
- out = [from_reply(v, items) for v in value]
184
+ out = [from_reply(v, items, policy, path) for v in value]
132
185
  live = S.branch_for(items, {}) if isinstance(items, dict) else None
133
- forced = _forced(live, False) if isinstance(live, dict) and S.is_object(live) else set()
186
+ forced = _forced(live, False, policy, path) if isinstance(live, dict) and S.is_object(live) else set()
134
187
  if forced: # an item holding only answers it was made to give is not an item the document has
135
188
  out = [x for x in out if not (isinstance(x, dict) and _blank({k: v for k, v in x.items() if k not in forced}))]
136
189
  return out
@@ -171,11 +224,40 @@ def _choice(node: Any) -> bool:
171
224
  or S.types_of(n) - {"null"} == {"boolean"})
172
225
 
173
226
 
174
- def _forced(obj: dict, must: bool) -> set:
175
- """Fields of an object answered without a "" choice: required, not nullable, yes/no or enum. In an object that
176
- may be absent and has nothing else to find, none are forced (forcing them would make the object up)."""
227
+ def _leaf(node: Any) -> bool:
228
+ """A single value (number, text, yes/no, enum), not an object, a list or a union holding one."""
229
+ if not isinstance(node, dict):
230
+ return False
231
+ return all(isinstance(n, dict) and not S.is_object(n) and not S.is_array(n) and "properties" not in n
232
+ for n in _live(node))
233
+
234
+
235
+ def _forced(obj: dict, must: bool, policy: Any = "choices", path: tuple = ()) -> set:
236
+ """Fields of an object that must be answered, by ``policy`` (``fill_policy``):
237
+
238
+ - "choices" (default): required, non-nullable yes/no and enum fields;
239
+ - True: those, and every required, non-nullable number and text field of an object that is always present
240
+ (in a section that may be absent, numbers and text are not forced: that would make the section up);
241
+ - a set of paths: the choices, and the listed fields wherever they are;
242
+ - False: none.
243
+
244
+ In an object that may be absent, if every field would be forced none is: nothing would be left to show
245
+ whether the document has it."""
246
+ if policy is False:
247
+ return set()
177
248
  req, props = set(obj.get("required") or []), obj.get("properties") or {}
178
- keys = {k for k, v in props.items() if k in req and isinstance(v, dict) and not _allows_null(v) and _choice(v)}
249
+
250
+ def eligible(k: str, v: Any) -> bool:
251
+ if not isinstance(v, dict):
252
+ return False
253
+ listed = isinstance(policy, set) and _norm_path(path + (k,)) in policy and _leaf(v)
254
+ if listed:
255
+ return True
256
+ if k not in req or _allows_null(v):
257
+ return False
258
+ return _choice(v) or (policy is True and must and _leaf(v))
259
+
260
+ keys = {k for k, v in props.items() if eligible(k, v)}
179
261
  return keys if must or len(keys) < len(props) else set()
180
262
 
181
263
 
@@ -51,3 +51,53 @@ def test_total_row_without_item_name_is_not_an_item():
51
51
  assert FR.amount_rows(t) == 2
52
52
  assert FR._category({"enum": ["a"]}) and FR._category({"anyOf": [{"enum": ["a"]}, {"type": "null"}]})
53
53
  assert not FR._category({"type": "string"})
54
+
55
+
56
+ def _flat(r, path=()):
57
+ out = {}
58
+ if r.get("type") == "object":
59
+ for k, v in r["properties"].items():
60
+ out.update(_flat(v, path + (k,)))
61
+ elif r.get("type") == "array":
62
+ out.update(_flat(r["items"], path))
63
+ else:
64
+ out[".".join(path)] = r
65
+ return out
66
+
67
+
68
+ DOC = {"type": "object", "required": ["name", "total", "paid", "items"], "properties": {
69
+ "name": {"type": "string"}, "total": {"type": "number"}, "paid": {"type": "boolean"},
70
+ "tax_id": {"type": "string"},
71
+ "items": {"type": "array", "items": {"type": "object", "required": ["sku", "kind"], "properties": {
72
+ "sku": {"type": "string"}, "kind": {"enum": ["a", "b"]}, "amount": {"type": "number"}}}}}}
73
+
74
+
75
+ def test_fill_policies():
76
+ pol = RS.fill_policy
77
+ f = _flat(RS.to_reply(DOC, policy=pol("choices")))
78
+ assert f["paid"]["enum"] == ["true", "false"] and RS.FILL_HINT not in f["name"].get("description", "")
79
+ assert RS.forced_paths(DOC, pol("choices")) == set()
80
+ f = _flat(RS.to_reply(DOC, policy=pol(True)))
81
+ assert RS.FILL_HINT in f["name"]["description"] and RS.FILL_HINT in f["total"]["description"]
82
+ assert RS.FILL_HINT in f["items.sku"]["description"] and RS.FILL_HINT not in f.get("tax_id", {}).get("description", "")
83
+ assert RS.forced_paths(DOC, pol(True)) == {"name", "total", "items.sku"}
84
+ f = _flat(RS.to_reply(DOC, policy=pol(False)))
85
+ assert "" in f["paid"]["enum"] and "" in f["items.kind"]["enum"]
86
+ p = pol(["tax_id", "items[].amount"])
87
+ f = _flat(RS.to_reply(DOC, policy=p))
88
+ assert RS.FILL_HINT in f["tax_id"]["description"] and RS.FILL_HINT in f["items.amount"]["description"]
89
+ assert f["paid"]["enum"] == ["true", "false"] and RS.FILL_HINT not in f["name"].get("description", "")
90
+ assert RS.forced_paths(DOC, p) == {"tax_id", "items.amount"}
91
+
92
+
93
+ def test_cli_fill_values():
94
+ from readanydoc.cli import _fill
95
+ assert _fill(None) == "choices" and _fill([]) is True and _fill(["none"]) is False
96
+ assert _fill(["a.b"]) == ["a.b"]
97
+
98
+
99
+ def test_spanned_total_row_is_not_an_item():
100
+ t = ("<table><tr><td>Product</td><td>Billing</td><td>Amount</td></tr>"
101
+ "<tr><td>A</td><td>Monthly</td><td>USD 1.00</td></tr><tr><td>B</td><td>One-time</td><td>USD 5.00</td></tr>"
102
+ "<tr><td colspan='2'>Monthly recurring</td><td>USD 1.00</td></tr></table>")
103
+ assert FR.amount_rows(t) == 2
File without changes
File without changes
File without changes