code/chapter15/Helloagents-AI-Town/SETUP_GUIDE.md
方法A: 使用Git
git clone https://github.com/datawhalechina/hello-agents
cd chapter15
方法B: 下载ZIP
cd backend
python -m venv venv
Windows:
venv\Scripts\activate
macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
cd ../HelloAgents
pip install -e .
cd ../backend
cp .env.example .env
# API配置
API_HOST=0.0.0.0
API_PORT=8000
# LLM配置 - 请填写你的API密钥
LLM_API_KEY=sk-your-api-key-here
LLM_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-4
# NPC更新间隔(秒)
NPC_UPDATE_INTERVAL=30
重要: 请将 LLM_API_KEY 替换为你的实际API密钥!
cd backend
python main.py
预期输出:
📝 对话日志文件: .../backend/logs/dialogue_2025-10-15.log
📂 日志目录: .../backend/logs
============================================================
🎮 赛博小镇后端服务启动中...
============================================================
...
✅ 所有服务已启动!
📡 API地址: http://0.0.0.0:8000
📚 API文档: http://0.0.0.0:8000/docs
============================================================
Helloagents-AI-Town/helloagents-ai-town/scenes/main.tscn访问: http://localhost:8000/docs
cd backend
python view_logs.py tail
A: 检查:
A: 检查:
A: 检查:
现在你可以在游戏中与NPC对话了!