Files
ai-ticket-platform/docs/development/local-setup.md
2026-07-14 14:13:40 +08:00

89 lines
2.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.
# Local Setup
## Prerequisites
- Python 3.12
- Node.js 22
- Docker Desktop
## First Run
```powershell
Copy-Item .env.example .env
python -c "import base64,secrets; print(base64.urlsafe_b64encode(secrets.token_bytes(32)).decode())"
```
将输出写入 `.env` 的 `AI_CREDENTIAL_ENCRYPTION_KEY`。该值缺失时,系统会拒绝保存模型渠道凭证;已经保存凭证后不要随意更换主密钥。
完整应用(PostgreSQL、Redis、MinIO、Django、Celery worker、Celery Beat、React):
```powershell
cd infra
docker compose --env-file ../.env up --build
```
只启动本地基础设施、在宿主机运行前后端时:
```powershell
cd infra
docker compose -f docker-compose.local.yml --env-file ../.env up -d
```
首次启动时,backend 容器会自动等待 PostgreSQL、执行数据库迁移,并初始化企业后台治理数据。
Backend:
- API: http://localhost:8000/api/docs
- Health: http://localhost:8000/api/system/health
Frontend:
- App: http://localhost:5173
默认管理员:
- 账号: `admin`
- 密码: `admin12345`
- 可通过 `.env` 中的 `DJANGO_SUPERUSER_USERNAME`、`DJANGO_SUPERUSER_PASSWORD`、`DJANGO_SUPERUSER_EMAIL` 修改。
## Backend Tests
```bash
cd backend
python -m pip install -e ".[dev]"
pytest -v
```
## Frontend Checks
```bash
cd frontend
npm install
npm run test:run
npm run lint
npm run typecheck
npm run build
```
## AI Platform Demo
1. 使用管理员账号打开 `#/modelhub/providers`,创建 OpenAI-compatible 渠道和文本模型,并执行异步连通测试。
2. 取得模型配置 ID 后创建预置草稿:
```powershell
cd backend
python manage.py seed_ai_demo --deployment-id 1
```
3. 在 `#/skills` 检查、编辑并发布三个 Skill。
4. 在 `#/agents` 编辑技术支持分析 Agent 的模型、步骤和输入映射,先运行草稿沙箱,再发布并运行正式版本。
5. 在 `#/agent-runs` 查看执行脊柱、每步输入输出、调用尝试、Token、耗时和配置快照。
完整验收步骤见 [AI 平台配置演示版验收](ai-platform-demo-acceptance.md)。
## Stage 1 API Smoke Tests
- Tickets: `GET http://localhost:8000/api/tickets`
- Ticket export: `GET http://localhost:8000/api/tickets/export`
- Solutions: `GET http://localhost:8000/api/solutions`