| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- from __future__ import annotations
- """候选筛选结果模型:RankedFlightCandidate与RankedHotelCandidate等经排序的候选。"""
- from typing import Any, Literal
- from pydantic import Field
- from app.schemas.common import AppModel
- class RankedFlightCandidate(AppModel):
- """经过确定性评分的单个航班候选。"""
- option_id: str
- score: float = Field(
- ge=0,
- le=100,
- )
- reasons: list[str] = Field(
- default_factory=list
- )
- warnings: list[str] = Field(
- default_factory=list
- )
- flight: dict[str, Any]
- class RoundTripOption(AppModel):
- """一个完整的往返航班组合。"""
- combination_id: str
- score: float = Field(
- ge=0,
- le=100,
- )
- # 返程查询返回的完整往返接口报价(不是去程+返程的加总)。
- quoted_price: float | None = None
- currency: str = "CNY"
- outbound: dict[str, Any]
- return_flight: dict[str, Any]
- reasons: list[str] = Field(
- default_factory=list
- )
- warnings: list[str] = Field(
- default_factory=list
- )
- class RankedHotelCandidate(AppModel):
- """经过确定性评分的酒店候选。"""
- hotel_id: str
- score: float = Field(
- ge=0,
- le=100,
- )
- reasons: list[str] = Field(
- default_factory=list
- )
- warnings: list[str] = Field(
- default_factory=list
- )
- hotel: dict[str, Any]
- class CandidateSelectionResult(AppModel):
- """航班和酒店候选筛选结果。"""
- flight_type: Literal[
- "one_way",
- "round_trip",
- ]
- # 往返搜索时,用于发起返程查询的去程候选。
- outbound_candidates: list[
- RankedFlightCandidate
- ] = Field(
- default_factory=list
- )
- # 单程旅行使用。
- one_way_options: list[
- RankedFlightCandidate
- ] = Field(
- default_factory=list
- )
- # 往返旅行使用。
- round_trip_options: list[
- RoundTripOption
- ] = Field(
- default_factory=list
- )
- hotels: list[
- RankedHotelCandidate
- ] = Field(
- default_factory=list
- )
- warnings: list[str] = Field(
- default_factory=list
- )
|