forked from zhouruizhe/gmTouringMiniApp
Add check-in feature and update travel planner UI
This commit is contained in:
+3
-7
@@ -2,6 +2,8 @@
|
||||
|
||||
This FastAPI service is the server-only AI boundary for the Guangming travel POC. It defaults to deterministic `mock` mode. Model credentials belong only in `server/.env` or the deployment environment and must never be added to the mini-program build.
|
||||
|
||||
This service is reserved for a later AI integration phase. The current mini-program `createPlan` entry point is hard-wired to the local planner and does not call this service.
|
||||
|
||||
## Contract
|
||||
|
||||
`POST /api/v1/plans` accepts a planning request and a coordinate-free POI whitelist:
|
||||
@@ -12,15 +14,9 @@ This FastAPI service is the server-only AI boundary for the Guangming travel POC
|
||||
"preferences": {
|
||||
"destination": "深圳市光明区",
|
||||
"themes": ["亲子"],
|
||||
"duration": "half_day",
|
||||
"pace": "moderate",
|
||||
"interests": ["自然风光"],
|
||||
"adults": 2,
|
||||
"children": 1,
|
||||
"childAges": [6],
|
||||
"transport": "public_transport",
|
||||
"budgetLevel": "standard",
|
||||
"extraRequirements": ""
|
||||
"transport": "public_transport"
|
||||
},
|
||||
"durationMinutes": 240,
|
||||
"selectedPoiIds": ["poi_a", "poi_b"],
|
||||
|
||||
@@ -28,8 +28,6 @@ def _score(candidate: PoiCandidate, request: PlanRecommendationRequest) -> int:
|
||||
for interest in request.preferences.interests:
|
||||
desired_tags.update(INTEREST_TAGS.get(interest, set()))
|
||||
score += len(desired_tags.intersection(candidate.tag_codes)) * 8
|
||||
if request.preferences.children and "family_friendly" in candidate.tag_codes:
|
||||
score += 8
|
||||
return score
|
||||
|
||||
|
||||
|
||||
@@ -55,24 +55,12 @@ Interest = Literal["自然风光", "文化场馆", "生态科普", "美食", "
|
||||
class TravelPreferences(APIModel):
|
||||
destination: Literal["深圳市光明区"] = "深圳市光明区"
|
||||
themes: list[Theme] = Field(default_factory=list, max_length=5)
|
||||
duration: Duration
|
||||
pace: Pace
|
||||
interests: list[Interest] = Field(default_factory=list, max_length=5)
|
||||
adults: int = Field(default=2, ge=0, le=20)
|
||||
children: int = Field(default=0, ge=0, le=20)
|
||||
child_ages: list[int] = Field(default_factory=list, max_length=20)
|
||||
transport: Transport = Transport.PUBLIC_TRANSPORT
|
||||
budget_level: BudgetLevel = BudgetLevel.STANDARD
|
||||
extra_requirements: str = Field(default="", max_length=500)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_group(self) -> "TravelPreferences":
|
||||
if self.adults + self.children < 1:
|
||||
raise ValueError("出行总人数至少为 1")
|
||||
if self.child_ages and len(self.child_ages) != self.children:
|
||||
raise ValueError("儿童年龄数量必须与儿童人数一致")
|
||||
if any(age < 0 or age > 17 for age in self.child_ages):
|
||||
raise ValueError("儿童年龄须在 0 至 17 岁之间")
|
||||
if len(set(self.themes)) != len(self.themes):
|
||||
raise ValueError("出行主题不能重复")
|
||||
if len(set(self.interests)) != len(self.interests):
|
||||
|
||||
@@ -16,15 +16,9 @@ def preferences():
|
||||
return {
|
||||
"destination": "深圳市光明区",
|
||||
"themes": ["亲子"],
|
||||
"duration": "half_day",
|
||||
"pace": "moderate",
|
||||
"interests": ["自然风光"],
|
||||
"adults": 2,
|
||||
"children": 1,
|
||||
"childAges": [6],
|
||||
"transport": "public_transport",
|
||||
"budgetLevel": "standard",
|
||||
"extraRequirements": "",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,15 +14,9 @@ def custom_request() -> PlanRecommendationRequest:
|
||||
"preferences": {
|
||||
"destination": "深圳市光明区",
|
||||
"themes": ["朋友"],
|
||||
"duration": "half_day",
|
||||
"pace": "moderate",
|
||||
"interests": ["自然风光"],
|
||||
"adults": 2,
|
||||
"children": 0,
|
||||
"childAges": [],
|
||||
"transport": "public_transport",
|
||||
"budgetLevel": "standard",
|
||||
"extraRequirements": "",
|
||||
},
|
||||
"durationMinutes": 120,
|
||||
"selectedPoiIds": ["poi_a", "poi_b", "poi_c"],
|
||||
|
||||
Reference in New Issue
Block a user