LangChain开发获取天气的Agent教程
1) 项目结构
weather-agent/
├─ app/
│ ├─ core/
│ │ ├─ config.py # 配置与环境变量
│ │ ├─ logging.py # 结构化日志
│ │ └─ observability.py # Prometheus/OTEL/ LangSmith
│ ├─ llm/
│ │ ├─ model.py # LLM 客户端与 LangChain 初始化
│ │ └─ agent.py # Agent / Tool / Prompt
│ ├─ tools/
│ │ └─ weather.py # 天气工具(API 封装、重试、超时、缓存)
│ ├─ api/
│ │ ├─ schemas.py # Pydantic 请求/响应模型
│ │ └─ routes.py # FastAPI 路由(/v1/weather, /healthz, /metrics)
│ ├─ main.py # FastAPI 入口
│ └─ __init__.py
├─ tests/
│ ├─ test_weather_tool.py
│ └─ test_api.py
├─ requirements.txt
├─ Dockerfile
├─ docker-compose.yaml
├─ k8s/
│