| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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
-
|