fix(backend): 修复视频生成接口401认证失败问题

- 修正可灵视频任务提交时认证失败导致的视频生成错误
- 解决接口返回500错误的问题
- 优化视频生成相关的错误日志提示
- 保证上传目录准备状态的正确显示
- 提升后台服务日志的稳定性和连续性
This commit is contained in:
2026-04-13 14:41:02 +08:00
parent 7f84a04e27
commit 18dfc75372
10 changed files with 228 additions and 14 deletions

View File

@@ -27,8 +27,9 @@ class DesignCreate(BaseModel):
"""创建设计请求"""
category_id: int = Field(..., description="品类ID")
sub_type_id: Optional[int] = Field(None, description="子类型ID")
sub_type_name: Optional[str] = Field(None, max_length=50, description="自定义子类型名称")
color_id: Optional[int] = Field(None, description="颜色ID")
prompt: str = Field(..., min_length=1, max_length=2000, description="设计需求")
prompt: Optional[str] = Field(None, max_length=2000, description="设计需求")
carving_technique: Optional[str] = Field(None, max_length=50, description="雕刻工艺")
design_style: Optional[str] = Field(None, max_length=50, description="设计风格")
motif: Optional[str] = Field(None, max_length=100, description="题材纹样")

View File

@@ -139,7 +139,7 @@ async def _generate_ai_images(
prompt_text = build_prompt(
category_name=category.name,
view_name=view_name,
sub_type_name=sub_type.name if sub_type else None,
sub_type_name=sub_type.name if sub_type else design_data.sub_type_name,
color_name=color.name if color else None,
user_prompt=design_data.prompt,
carving_technique=design_data.carving_technique,
@@ -244,7 +244,7 @@ def _generate_mock_fallback(
save_path = os.path.join(settings.UPLOAD_DIR, "designs", f"{design.id}.png")
image_url = generate_mock_design(
category_name=category.name,
sub_type_name=sub_type.name if sub_type else None,
sub_type_name=sub_type.name if sub_type else design_data.sub_type_name,
color_name=color.name if color else None,
prompt=design_data.prompt,
save_path=save_path,

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@@ -317,3 +317,125 @@ INFO: 127.0.0.1:58331 - "GET /api/categories/12/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58335 - "GET /api/categories/13/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58341 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58340 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58408 - "GET /api/auth/me HTTP/1.1" 200 OK
INFO: 127.0.0.1:58417 - "GET /api/auth/me HTTP/1.1" 200 OK
INFO: 127.0.0.1:58419 - "GET /api/categories HTTP/1.1" 200 OK
INFO: 127.0.0.1:58504 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58503 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58509 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58511 - "GET /api/categories/2/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58517 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58519 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58527 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58529 - "GET /api/categories/2/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58535 - "GET /api/categories/3/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58534 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58550 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58551 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58638 - "GET /api/categories/13/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58644 - "GET /api/categories/12/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58643 - "GET /api/categories/12/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58649 - "GET /api/categories/11/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58651 - "GET /api/categories/11/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58658 - "GET /api/categories/10/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58659 - "GET /api/categories/10/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58665 - "GET /api/categories/9/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58664 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58670 - "GET /api/categories/8/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58671 - "GET /api/categories/8/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58677 - "GET /api/categories/7/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58678 - "GET /api/categories/7/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58684 - "GET /api/categories/6/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58686 - "GET /api/categories/6/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58692 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58691 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
WARNING: StatReload detected changes in 'app/schemas/design.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [903]
👋 应用已关闭
INFO: Started server process [3994]
INFO: Waiting for application startup.
INFO: Application startup complete.
✅ 上传目录已准备: uploads
INFO: 127.0.0.1:58700 - "GET /api/categories/2/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58699 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58708 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58709 - "GET /api/categories/3/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58715 - "GET /api/categories/4/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58716 - "GET /api/categories/4/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58721 - "GET /api/categories/5/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58722 - "GET /api/categories/5/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58727 - "GET /api/categories/6/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58728 - "GET /api/categories/6/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58734 - "GET /api/categories/7/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58733 - "GET /api/categories/7/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58739 - "GET /api/categories/8/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58740 - "GET /api/categories/8/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58746 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58747 - "GET /api/categories/9/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58751 - "GET /api/categories/10/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58753 - "GET /api/categories/10/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58758 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58759 - "GET /api/categories/9/colors HTTP/1.1" 200 OK
WARNING: StatReload detected changes in 'app/services/design_service.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [3994]
👋 应用已关闭
INFO: Started server process [4005]
INFO: Waiting for application startup.
INFO: Application startup complete.
WARNING: StatReload detected changes in 'app/services/design_service.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [4005]
✅ 上传目录已准备: uploads
👋 应用已关闭
INFO: Started server process [4016]
INFO: Waiting for application startup.
INFO: Application startup complete.
✅ 上传目录已准备: uploads
INFO: 127.0.0.1:58910 - "GET /api/categories HTTP/1.1" 200 OK
INFO: 127.0.0.1:58916 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58918 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58925 - "GET /api/categories HTTP/1.1" 200 OK
INFO: 127.0.0.1:58930 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:58931 - "GET /api/categories/2/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58937 - "GET /api/categories/3/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:58936 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK
WARNING: StatReload detected changes in 'app/schemas/design.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [4016]
👋 应用已关闭
INFO: Started server process [4272]
INFO: Waiting for application startup.
INFO: Application startup complete.
✅ 上传目录已准备: uploads
INFO: 127.0.0.1:59022 - "GET /api/auth/me HTTP/1.1" 200 OK
INFO: 127.0.0.1:59025 - "GET /api/categories HTTP/1.1" 200 OK
INFO: 127.0.0.1:59072 - "POST /api/auth/login HTTP/1.1" 200 OK
INFO: 127.0.0.1:59076 - "GET /api/auth/me HTTP/1.1" 200 OK
INFO: 127.0.0.1:59082 - "GET /api/categories HTTP/1.1" 200 OK
INFO: 127.0.0.1:59089 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK
INFO: 127.0.0.1:59090 - "GET /api/categories/1/colors HTTP/1.1" 200 OK
INFO: 127.0.0.1:59224 - "POST /api/designs/generate HTTP/1.1" 200 OK
INFO: 127.0.0.1:59331 - "GET /uploads/designs/28_0_8f1d51f1.png HTTP/1.1" 200 OK
INFO: 127.0.0.1:59345 - "GET /uploads/designs/28_2_afd0819c.png HTTP/1.1" 200 OK
INFO: 127.0.0.1:59348 - "GET /uploads/designs/28_3_597f23e1.png HTTP/1.1" 200 OK
INFO: 127.0.0.1:59352 - "GET /uploads/designs/28_1_652b3742.png HTTP/1.1" 200 OK
INFO: 127.0.0.1:50695 - "GET /projects.php HTTP/1.1" 404 Not Found
INFO: ('127.0.0.1', 55036) - "WebSocket /CLodopfuncs.js" 403
INFO: connection rejected (403 Forbidden)
INFO: connection closed
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [4272]
👋 应用已关闭
INFO: Stopping reloader process [63566]