from __future__ import annotations """多角色工作流共享状态:定义TravelState(TypedDict)及Supervisor决策、Workflow状态等类型枚举。""" from app.schemas.place import MapResearchResult from typing import Any, Literal from typing_extensions import TypedDict from app.schemas.travel_request import ( TravelRequest, ) from app.schemas.selection import ( CandidateSelectionResult, ) from app.schemas.route import ( RouteEvaluationResult, ) from app.schemas.itinerary import ItineraryPlan from app.schemas.validation import ( PlanValidationResult, ) from app.schemas.review import ( TripReviewResult, ) SupervisorDecision = Literal[ "replan", "finalize", "finalize_with_risks", "terminate", ] WorkflowStatus = Literal[ "running", "approved", "completed_with_risks", "failed", ] class TravelState(TypedDict, total=False): """旅行规划工作流共享状态。 后面会逐步加入航班、酒店、景点和路线结果。 """ user_query: str travel_request: TravelRequest missing_fields: list[str] errors: list[str] needs_clarification: bool clarification_question: str # 资源查询阶段新增 origin_airports: list[str] destination_airports: list[str] flight_search_result: dict[str, Any] hotel_search_result: dict[str, Any] resource_messages: list[Any] final_answer: str # 本阶段新增 map_research_result: MapResearchResult map_messages: list[Any] candidate_selection_result: ( CandidateSelectionResult ) selection_warnings: list[str] route_evaluation_result: RouteEvaluationResult route_warnings: list[str] itinerary_plan: ItineraryPlan planner_messages: list[Any] planning_attempts: int # 后续Reviewer要求重新规划时使用。 revision_feedback: list[str] plan_validation_result: PlanValidationResult validation_passed: bool validation_warnings: list[str] trip_review_result: TripReviewResult reviewer_messages: list[Any] review_passed: bool review_attempts: int supervisor_decision: SupervisorDecision supervisor_reason: str workflow_status: WorkflowStatus final_answer: str