| from __future__ import annotations
|
|
|
| import operator
|
| from typing import Annotated, TypedDict
|
|
|
| from langgraph.graph import add_messages
|
|
|
|
|
| class ImageRef(TypedDict):
|
| """Lightweight reference to an image stored on disk."""
|
| id: str
|
| path: str
|
| label: str
|
| page_num: int
|
| crop_type: str
|
| width: int
|
| height: int
|
|
|
|
|
| class CropTask(TypedDict):
|
| """A single crop+annotate instruction produced by the planner."""
|
| page_num: int
|
| crop_instruction: str
|
| annotate: bool
|
| annotation_prompt: str
|
| label: str
|
| priority: int
|
|
|
|
|
| class PageMetadata(TypedDict):
|
| """Structured description of a single PDF page, generated by background metadata extraction."""
|
| page_num: int
|
| sheet_id: str
|
| sheet_title: str
|
| discipline: str
|
| page_type: str
|
| description: str
|
| key_elements: list[str]
|
| spatial_coverage: str
|
|
|
|
|
| class DrawingReaderState(TypedDict):
|
|
|
| messages: Annotated[list, add_messages]
|
| question: str
|
|
|
|
|
| pdf_path: str
|
| page_image_dir: str
|
| num_pages: int
|
|
|
|
|
| page_metadata_json: str
|
|
|
|
|
| legend_pages: list[int]
|
| target_pages: list[int]
|
|
|
|
|
| crop_tasks: list[CropTask]
|
|
|
|
|
| image_refs: Annotated[list[ImageRef], operator.add]
|
|
|
|
|
| gemini_analysis: str
|
| gpt_analysis: str
|
| final_answer: str
|
|
|
|
|
| needs_more_investigation: bool
|
| investigation_round: int
|
| max_rounds: int
|
| enable_consensus: bool
|
| enable_annotation: bool
|
| status_message: str
|
|
|