feat(ai_engine): AI 生成引擎——视频路线动作生成管线 - #152
Conversation
- Add backend/Dockerfile with multi-stage build (uv + Python 3.12) - Add docker-compose.yml with backend and PostgreSQL services - Add db/init.sql for automatic database table initialization - Add .env.example with configuration template - PostgreSQL configured with port 7856 and secure password
…browser 三处让部署跑不起来的问题,都在这台服务器上实测定位: 1. 构建阶段 uv sync 超时。宿主机访问 pypi.org 需 8s,构建容器内默认超时会在 下载大包(uvloop)时 "operation timed out" 直接失败。改走国内镜像源并把 UV_HTTP_TIMEOUT 拉到 180s。 2. 容器起来即反复重启,报 "exec /app/.venv/bin/uvicorn: no such file or directory"。 文件其实存在,报的是它 shebang 指向的解释器——uv 装出来的 venv 里 shebang 与 .pth 都是绝对路径,builder 在 /build、runtime 在 /app,跨路径拷贝后解释器与 workspace 包全部失效。把 builder 的 WORKDIR 也改成 /app 即可。 3. 七牛上传 TLS 握手超时、媒体上传请求挂死。宿主机网卡 MTU 1480,而 compose 自建网络不继承 daemon 的 mtu 设置、默认仍是 1500,大包被丢。显式给网络设 1450 后,up-z0.qiniup.com 从握手超时 14s 变为 1.0s,上传恢复正常。 4. 浏览器跨域被全部拦下:OPTIONS 预检返回 405、响应无 access-control-* 头, 后端日志里连请求都看不到。挂上 CORSMiddleware,允许来源用 WINDUP_CORS_ORIGINS 覆盖,并放行 Vercel 预览域名。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
后端验证码/refresh_token 依赖 Redis,原 compose 只有 Postgres。 新增 redis:7-alpine 服务(含健康检查),backend depends_on 等待就绪, 环境变量 REDIS_URL=redis://redis:6379/0。
ORM 声明了 UniqueConstraint(user_id, project_name),但 init.sql 建表时遗漏。 生产 Postgres 并发创建同名项目不会触发 IntegrityError,API 兜底失效。 补上 CONSTRAINT uq_windup_project_user_name UNIQUE (user_id, project_name)。
…imiting - 注册/登录(邮箱+验证码+密码)、免密登录、刷新 token、登出、改密 - JWT 鉴权中间件(白名单放行 + request.state.current_user 注入) - 邮箱验证码(Redis 存储 + 冷却计时) - 接口限流中间件(Redis 滑动窗口 + 降级策略) - Redis 连接配置与客户端单例 - 22 个集成测试覆盖完整认证链路
- Add auth_client fixture with valid JWT token - Update test_project_api.py to use auth_client - Fix CI failures caused by auth middleware blocking unauthenticated requests
- workflow_run 模块:接口、ORM 模型、JSONB 节点树 schema - agent 模块:SSE 会话管理骨架 - project/character 模块:接口、ORM 模型、service 实现 - 统一异常处理器(BizException 继承体系) - media 上传 API
- server/generation → server/orchestrator(生成任务编排/调度) - orchestrator 模块:interface、model、service、task_repo、executor - generation API:图片生成 + 动作生成 + 任务轮询 - after_commit 回调修复任务行未提交竞态 - generation 端点从 JWT 取 user_id,加项目归属校验
- slicing: 帧提取(extract)、循环检测(loop)、一次性动作(oneshot) - strategy: 路线分发(VIDEO_I2V / PER_FRAME / PROC_IDLE)+ DerivationStrategy - postprocess: 像素化(pixelate)、root motion、sprite sheet 打包(pack) - prompt: 提示词构建(walk / jump / actions) - impl: CharacterGenerator 实现 - ports: GeneratedAction 输出接口 - test: 串联 smoke 测试
…e optional on macOS x86_64
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
| # ── 端点 ───────────────────────────────────────────────────────────────────── | ||
|
|
||
|
|
||
| @router.post("", response_model=Response[CharacterOut]) |
There was a problem hiding this comment.
High: this router never checks request.state.current_user against the owning project/character. As written, any authenticated user can create, list, read, update, or delete another user's characters by guessing ids.
| # 查找或创建用户 | ||
| user = session.scalar(select(User).where(User.email == input.email)) | ||
| if user is None: | ||
| user = User(email=input.email, email_verified_at=datetime.now(timezone.utc)) |
There was a problem hiding this comment.
High: this auto-register path leaves password_hash at the empty-string default. The password-login path later feeds that value into _verify_password() / bcrypt, so code-created accounts can hit a 500 instead of a normal bad-credentials error.
| pass # 风格参考图下载失败不阻断 | ||
|
|
||
| # 3. 构建提示词 | ||
| base = input.prompt or "Clean full-body character reference of the figure in the image." |
There was a problem hiding this comment.
Medium: negative_prompt from the API is never threaded into the prompt or provider call. Users can send it, but it has no effect on the generated image.
概述
AI 生成引擎模块:视频路线角色动作生成管线,包含帧提取、策略分发、后处理、提示词构建等完整链路。
包含内容
slicing(帧提取)
extract:视频帧提取(imageio/pyav)loop:循环检测(步态周期)oneshot:一次性动作裁剪strategy(策略分发)
base:DerivationStrategy 抽象 + ROUTE_MATRIXconcrete:VIDEO_I2V(walk/run/jump/attack)、PER_FRAME、PROC_IDLEpostprocess(后处理)
pixelate:像素化rootmotion:root motion 对齐pack:sprite sheet 打包prompt(提示词)
walk/jump/actions:侧视/正视提示词构建impl(实现)
CharacterGenerator:生成器实现ports:GeneratedAction 输出接口deps
测试
test_ai_engine_skeleton.py:串联 smoke 测试作者
关联