Travel Guide Agent is a local-first MVP for generating structured, practical, and professional travel plans in Chinese.
Travel Guide Agent 是一个面向本地运行的 MVP,用于生成结构化、实用、专业的中文旅游攻略。
It is built with FastAPI and an OpenAI-compatible SDK, and currently uses the DeepSeek API by default.
它基于 FastAPI 和 OpenAI-compatible SDK 构建,当前默认使用 DeepSeek API。
This version focuses on the core itinerary-generation workflow: turning free-form user travel requests into structured travel plans.
当前版本聚焦核心行程生成链路,即把自然语言旅行需求转换为结构化旅行攻略。
The agent is designed to behave like a professional travel advisor rather than a general encyclopedia.
这个 Agent 的定位是专业旅行顾问,而不是泛百科介绍器。
- Area overview / 区域概况
- Recommended trip length / 推荐游玩天数
- Daily itinerary planning / 每日行程安排
- Daily highlights and attractions / 每天的主要景点
- Basic transport advice / 简单交通建议
- Basic budget reference / 基础预算参考
- Common travel pitfalls / 避坑提醒
- Real-time flight or hotel search / 实时机票酒店查询
- Real-time restaurant opening hours / 实时餐厅营业时间
- Real-time attraction status / 实时景点开放状态
- Advanced map route optimization / 复杂地图路线优化
- Booking services / 预订服务
- Login system / 登录系统
- Payment system / 支付系统
- User database / 用户数据库
- RAG / 检索增强生成
- Map API integration / 地图 API 集成
travel-guide-agent/
├── app/
│ ├── __init__.py
│ ├── agent.py
│ ├── cli.py
│ ├── config.py
│ ├── llm/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── deepseek_client.py
│ │ └── provider.py
│ ├── main.py
│ ├── prompts/
│ ├── schemas/
│ ├── services/
│ ├── tools/
│ └── utils/
├── tests/
│ ├── __init__.py
│ ├── test_llm_provider.py
│ └── test_planner.py
├── .env.example
├── .gitignore
├── requirements.txt
├── start_agent.sh
└── README.md
- Python 3.12+ recommended / 推荐 Python 3.12+
- A valid DeepSeek API key / 可用的 DeepSeek API key
Copy the example file first:
先复制示例文件:
cp .env.example .envThen fill in the required values in .env:
然后在 .env 中填写必要配置:
LLM_PROVIDER=deepseek
DEEPSEEK_API_KEY=sk-xxxxxxxx
DEEPSEEK_BASE_URL=https://api.deepseek.com
DEEPSEEK_MODEL=deepseek-v4-flash
USD_TO_CNY_RATE=6.77
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4.1-miniThe project keeps OpenAI-related fields for future extensibility, but the current default provider is DeepSeek.
项目保留了 OpenAI 相关配置位以便后续扩展,但当前默认 provider 是 DeepSeek。
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtuvicorn app.main:app --reloadDefault local URL:
默认本地访问地址:
http://127.0.0.1:8000
If you want a simpler flow, use the startup script below. It will prepare the environment, ask for your DeepSeek API key, and launch a terminal chat session.
如果你想要更省事的启动方式,可以使用下面的脚本。它会自动准备环境、提示你输入 DeepSeek API key,并直接启动终端对话模式。
zsh start_agent.shWhat the script does / 脚本会自动执行:
- Check and create
.venvif needed / 检查并在需要时创建.venv - Install dependencies if needed / 在需要时安装依赖
- Copy
.env.exampleto.envif.envdoes not exist / 若.env不存在则自动复制 - Prompt for
DEEPSEEK_API_KEY/ 提示输入DEEPSEEK_API_KEY - Start the interactive chat CLI / 启动交互式命令行对话
Important notes / 注意事项:
- The API key entered here is only used for the current session and is not automatically written to
.env
在这里输入的 API key 仅在当前会话内生效,不会自动写入.env - You can exit the chat by typing
exit,quit, orq
你可以输入exit、quit或q退出对话
Example prompt / 示例输入:
Tokyo for 5 days, I like anime and food, and I don't want the trip to feel too tiring.
东京 5 天,喜欢动漫和美食,不想太累
curl http://127.0.0.1:8000/healthcurl -X POST "http://127.0.0.1:8000/api/plan" \
-H "Content-Type: application/json" \
-d '{"user_input":"东京 5 天,喜欢动漫和美食,不想太累"}'{
"success": true,
"data": {
"answer_markdown": "【城市概况】\n...\n【避坑提醒】\n...",
"answer_markdown_path": "/absolute/path/to/outputs/tokyo-5-days-20260602-120000.md",
"detected_city": "东京",
"detected_days": 5,
"need_day_recommendation": false,
"token_usage": {
"prompt_tokens": 1200,
"completion_tokens": 1800,
"total_tokens": 3000,
"estimated_cost_usd": 0.000672,
"estimated_cost_cny": 0.004549,
"pricing_note": "Estimated cost based on current pricing."
},
"budget_references": [],
"daily_plans": [],
"itinerary_items": [],
"transport_advice": [],
"pitfall_reminders": []
}
}Each successful /api/plan request saves one complete travel plan as a single .md file under the local outputs/ directory.
每次成功调用 /api/plan,都会把整份完整攻略保存为一个 .md 文件,放在本地 outputs/ 目录下。
The saved file path is returned in answer_markdown_path.
保存路径会通过 answer_markdown_path 字段返回。
The response includes token usage, estimated USD cost, and estimated CNY cost.
接口返回中会包含 token 用量、美元费用估算和人民币费用估算。
The CNY estimate is calculated using USD_TO_CNY_RATE.
人民币估算通过 USD_TO_CNY_RATE 进行换算。
This is an estimate only and may differ from the actual provider billing amount.
这里展示的是估算值,可能与供应商最终计费存在差异。
{
"success": false,
"error": {
"message": "Error message / 错误说明"
}
}-
DEEPSEEK_API_KEY missing
Make sureDEEPSEEK_API_KEYis set in.env, or enter it when usingzsh start_agent.sh.
请确认.env中已配置DEEPSEEK_API_KEY,或者在使用zsh start_agent.sh时手动输入。 -
401 Unauthorized
This usually means the token is incorrect, expired, or not authorized.
这通常表示 token 错误、已过期,或者权限不足。 -
model not found
Check whetherDEEPSEEK_MODELis correct. The current default isdeepseek-v4-flash.
请检查DEEPSEEK_MODEL是否正确,当前默认值为deepseek-v4-flash。 -
insufficient balance
This usually means your account balance or available quota is insufficient.
这通常表示你的账户余额或可用额度不足。 -
Do not commit
.env
.envcontains secrets and must not be pushed to GitHub. It is already ignored by.gitignore.
.env包含敏感信息,不应提交到 GitHub;项目已通过.gitignore忽略该文件。
- Add
OpenAIClientunderapp/llm// 在app/llm/下新增OpenAIClient - Integrate a real travel knowledge base or RAG / 接入真实旅行知识库或 RAG
- Add route-planning or map features / 增加路线规划或地图能力
- Integrate hotel, flight, and restaurant search / 接入酒店、机票和餐厅搜索
- Support multi-city travel planning / 支持多城市联游规划
- Provide richer structured output for frontend rendering / 为前端渲染提供更丰富的结构化输出