Files
fastapi/backend/README.md
T
2026-06-03 15:51:46 +08:00

46 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Backend
医疗问诊 Agent FastAPI 后端工程。
## 启动
```powershell
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
cd ..
copy .env.example .env
cd backend
uvicorn app.main:app --host 127.0.0.1 --port 9000
```
Swagger
```text
http://127.0.0.1:9000/docs
```
## 配置
后端读取项目根目录 `.env`。核心配置:
```env
DATABASE_URL=mysql+pymysql://root:<password>@mysql:3306/medical_platform?charset=utf8mb4
MYSQL_URL=mysql+aiomysql://root:<password>@mysql:3306/medical_platform?charset=utf8mb4
REDIS_URL=redis://redis:6379/0
AUTH_USER_ME_URL=http://django:8000/api/user/users/me/
LLM_API_KEY=
```
真实密码、API Key 和 access token 只写入部署环境或本地 `.env`
## 核心约束
- 用户身份只来自 `Authorization: Bearer <access_token>`
- 后端转发 token 到 Django 用户中心 `/api/user/users/me/`
- Django 返回的 `id` 是本系统内部用户隔离字段。
- 问诊消息进入短期 memory,不作为长期历史保存。
- 检查检验结果只从数据库读取。
- 完整训练结束后保存 `training_record``training_score_detail`
- LLM 调用统一经过 `app/agents/llm_adapter.py`