| | """State schema for the Code Compliance Bot β extends drawing_reader patterns."""
|
| | 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."""
|
| | 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."""
|
| | page_num: int
|
| | sheet_id: str
|
| | sheet_title: str
|
| | discipline: str
|
| | page_type: str
|
| | description: str
|
| | key_elements: list[str]
|
| | spatial_coverage: str
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | class CodeQuery(TypedDict):
|
| | """A single code lookup request produced by the planner or analyst."""
|
| | query: str
|
| | focus_area: str
|
| | context: str
|
| | priority: int
|
| |
|
| |
|
| | class CodeSection(TypedDict):
|
| | """A retrieved code section from ChromaDB."""
|
| | section_full: str
|
| | code_type: str
|
| | parent_major: str
|
| | text: str
|
| | relevance: str
|
| |
|
| |
|
| | class AgentMessage(TypedDict):
|
| | """A single message in the inter-agent discussion log."""
|
| | timestamp: str
|
| | agent: str
|
| | action: str
|
| | summary: str
|
| | detail: str
|
| | evidence_refs: list[str]
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | class ComplianceState(TypedDict):
|
| | """Full state for the code compliance LangGraph workflow."""
|
| |
|
| |
|
| | 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]
|
| | code_queries: list[CodeQuery]
|
| |
|
| |
|
| | image_refs: Annotated[list[ImageRef], operator.add]
|
| |
|
| |
|
| | code_sections: Annotated[list[CodeSection], operator.add]
|
| | code_report: str
|
| | code_chapters_fetched: list[str]
|
| |
|
| |
|
| | compliance_analysis: str
|
| | reviewer_analysis: str
|
| | final_verdict: str
|
| |
|
| |
|
| | discussion_log: Annotated[list[AgentMessage], operator.add]
|
| |
|
| |
|
| | additional_crop_tasks: list[CropTask]
|
| | additional_code_queries: list[CodeQuery]
|
| | needs_more_investigation: bool
|
| | investigation_round: int
|
| | max_rounds: int
|
| |
|
| |
|
| | enable_consensus: bool
|
| | enable_annotation: bool
|
| |
|
| |
|
| | status_message: Annotated[list[str], operator.add]
|
| |
|
| |
|
| |
|
| |
|
| | DrawingReaderState = ComplianceState
|
| |
|