[问题/Issue] 章节13.2.5:示例代码中的 TripPlanRequest 未在 app.models.schemas 文件中定义

Author: flyingmyloCreated Sep 4, 2026Updated Sep 4, 2026
Labelsdocumentation

1. 遇到问题的章节 / Affected Chapter

13.2.5

2. 问题类型 / Issue Type

代码错误 / Code Error

3. 具体问题描述 / Problem Description

文件:code/chapter13/helloagents-trip-planner/backend/app/models/schemas.py 该文件中未定义TripPlanRequest

但是示例代码中引入了该模型 from app.models.schemas import TripPlanRequest,TripPlan

4. 问题重现材料 / Reproduction Materials

示例代码如下:

from fastapi import FastAPI
from app.models.schemas import TripPlanRequest,TripPlan

app = FastAPI()

@app.post("/api/trip/plan",response_model=TripPlan)
async def create_trip_plan(request: TripPlanRequest) -> TripPlan:
    """
    创建旅行计划
    
    FastAPI自动:
    1. 验证请求数据(TripPlanRequest)
    2. 验证响应数据(TripPlan)
    3. 生成OpenAPI文档
    """
    trip_plan = await generate_trip_plan(request)
    return trip_plan

5. 补充信息 / Additional Information

No response

确认事项 / Verification

  • 我已阅读过相关章节的文档 / I have read the relevant chapter documentation
  • 我已搜索过现有的Issues,确认此问题未被报告 / I have searched existing Issues and confirmed this hasn't been reported
  • 我已尝试过基本的故障排除(如重启、重新安装依赖等) / I have tried basic troubleshooting (restart, reinstall dependencies, etc.)

Source: datawhalechina/hello-agents