Spaces:
Sleeping
Sleeping
File size: 1,032 Bytes
db4ba8d dd9584b db4ba8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """
TradeFlow AI — LangGraph State Definition
"""
from operator import add
from typing import Annotated, TypedDict
class DocumentState(TypedDict):
doc_id: str
doc_type: str
storage_path: str
pages: list[str] # Base64 encoded images or temporary paths
extracted_data: dict | None
quality_score: float
ocr_method: str | None
error: str | None
ocr_candidates: dict
ocr_conflicts: list[dict]
field_confidences: dict[str, float]
class ExtractionGraphState(TypedDict):
"""The state of the document extraction LangGraph."""
batch_id: str
company_id: str
documents: list[DocumentState]
combined_data: dict
validation_results: list[dict]
needs_human_review: bool
risk_level: str
customs_readiness_score: float | None
crs_grade: str | None
rejection_probability: float | None
risk_features: dict
ocr_conflicts: list[dict]
field_confidences: dict[str, float]
# Keep track of which node executed
steps: Annotated[list[str], add]
|