A Tiny Guide to Our Invoice Processing Flow
Flow Diagram
flowchart TD
subgraph Initialization
A["Start: run_invoice_graph.py"]
end
subgraph Graph_Execution
B["1. extract_pdf"]
C["2. ocr_if_needed"]
D["3. signature"]
E["4. check_cache"]
F{"5. should_reuse_or_search"}
G["6a. milvus_suggest\n(similarity search)"]
H{"7. should_use_suggest_or_learn"}
I["8a. learn_and_stage\n(create staging template)"]
J1["6b. extract_using_suggested_template"]
J2["8b. extract_using_learned_template"]
R["9. extract_fields\n(normalize + math checks)"]
K["10. vision_validate"]
L{"11. should_pass_or_review"}
M["12a. promote_template"]
N["12b. mark_for_review"]
O["13. done"]
P["14. END"]
end
subgraph Final_Output
Q["Print JSON Summary"]
end
A --> B --> C --> D --> E --> F
F -- "reuse" --> R
F -- "search" --> G --> H
H -- "use_suggest" --> J1 --> R
H -- "learn" --> I --> J2 --> R
R --> K --> L
L -- "pass" --> M --> O
L -- "review" --> N --> O
O --> P --> Q
Mind Map (Expandable + Zoomable)
# Invoice Processing
## Initialization
- run `run_invoice_graph.py`
- state: { pdf_path, role="manager" }
## Extract
- extract_pdf
- ocr_if_needed
## Signature & Cache
- signature (hash + vendor)
- check_cache
## Decision: reuse or search
- reuse → **9. extract_fields**
- search → **6a. milvus_suggest**
## After suggest
- Found Similar → **6b. extract_using_suggested_template**
- Learn New → **8a. learn_and_stage** → **8b. extract_using_learned_template** → **9. extract_fields**
## Validate
- vision_validate → should_pass_or_review
## Finalize
- pass → promote_template → done
- review → mark_for_review → done
## Output
- END → print JSON summary
## Env & Auth
- APP_ROLE="manager"
- AUTO_PROMOTE_THRESHOLD=1
Tools used: Mermaid & Markmap. Expand nodes by clicking, zoom with mouse scroll, drag to pan.
No comments:
Post a Comment