Commit Graph

22 Commits

Author SHA1 Message Date
31c41ec7e9 优化海报生成模块的内容 2026-07-31 21:42:32 +08:00
11f57487fa 更新一版海报和PPT生成优化 2026-07-31 20:05:34 +08:00
b8c4e8b672 主要完成内容:
修复 PPT 异步任务无法生成的问题,包括任务变量引用错误、失败状态回写、心跳缺失任务恢复。
脱敏改为保司/产品后台统一配置,生成端不再让用户选择;任务创建时保存策略快照。
保司支持独立控制 PPT、海报 Logo 显示。
PPT 核验新增吸烟状态、币种及三个条件字段。
利益演示、退保提取调整为警告,不再阻止生成。
PPT 生成完成后可以直接返回数据核验页修改。
建立不同险种、单图/长图共六套海报字段画像。
PPT“生成场景”支持后台新增、启停和删除。
保司、产品、PPT 模板、文案模板均支持安全删除。
内置模板禁止删除,只允许停用;存在关联数据时拒绝危险删除。
补充策略变更及删除审计日志。
更新 API 文档、部署文档及修复计划实施记录。
关键交付文件:
[数据库迁移 migrate_027.py](D:/work/code/python/coding/baodanagent/api/insurance/db/migrate_027.py)
[海报字段画像 field_profiles.py](D:/work/code/python/coding/baodanagent/api/insurance/poster/field_profiles.py)
[动态场景服务 scenarios.py](D:/work/code/python/coding/baodanagent/api/insurance/ppt/scenarios.py)
[新增回归测试](D:/work/code/python/coding/baodanagent/tests/ppt_poster_optimization_test.py)
[优化修复计划书](D:/work/code/python/coding/baodanagent/docs/保险智能客服系统_PPT与海报优化修复计划书_20260731.md)
验证结果:
核心链路测试:37 passed,1 skipped
扩展回归测试:140 passed
PPT 渲染器测试:6 passed
前端生产构建:通过
Python 编译检查:通过
完整测试集:190 passed,1 failed
唯一失败为 tests/test_chat_save.py::test_chat_logs_query 未建立 Flask application context,与本次 PPT/海报链路无关。
2026-07-31 14:10:24 +08:00
f23b08eec6 07-29 PPT生成优化第一阶段完成:
已完成约 40%(阶段 1 + 阶段 2 + 阶段 3 基础编辑),覆盖了计划书中最核心的 P0 需求:

 真实预览(Canvas 方案替代了 LibreOffice 方案)
 质量检查(6 自动 + 4 人工)
 三栏结果工作台
 基础文字编辑
2026-07-29 21:26:48 +08:00
bf90801f28 07-29 修复一版问题PPT 能够上传了 2026-07-29 17:24:34 +08:00
6dfd652a57 07-29 修复一版问题PPT 能够上传了 2026-07-29 15:47:50 +08:00
74dbb32028 07-29 修复一版问题 2026-07-29 12:19:26 +08:00
f58940e719 修复BUG 2026-07-28 21:01:34 +08:00
fa67b83bbf 核心改进:
小册子解析:上传后3秒内返回,解析通过 Celery 异步执行,状态流转 pending → queued → parsing → parsed/failed,失败保留错误原因,启动时自动恢复卡住任务
保司Logo:支持多张图片上传、设主图、删除、排序,主图自动同步到 logo_url 保持向后兼容
文件存储:统一使用 get_storage_root() 持久化目录,Docker 重启不丢文件
2026-07-28 20:35:28 +08:00
8192f6a783 07-27 PDF提取优化 2026-07-28 16:45:14 +08:00
0b69978812 回复提交 2026-07-27 15:40:58 +08:00
e3479f0546 上线阻断问题全部修复
#	问题	修复	文件
1	前端构建失败(引号错误)	size="small type=" → size="small" type="	PosterHistoryPage.vue
2	migrate_014 ORM vs 缺失列	全部改为原始 SQL,不再引用 ORM 模型	migrate_014.py
3	cleanup 字段名错误	output_path → ppt_path	cleanup.py
4	文案生成 case 越权	添加 case.user_id != user_id 校验	poster/service.py
5	存储路径未接通持久化卷	全部改用 get_storage_root()(默认 /app/api/storage/insurance)	config.py, ppt/routes.py, poster/service.py, poster/tasks.py
高风险问题修复
#	问题	修复	文件
6	migrate_019 rollback 撤销成功字段	每个 ALTER 后立即 commit,失败只回滚当前语句	migrate_019.py
7	迁移锁 Windows 不兼容 + 句柄未持久化	全局变量保存锁句柄,支持 Windows msvcrt	api/insurance/db/__init__.py
8	PDF 校验异常时放行	异常返回 False(文件损坏)	security.py
9	健康检查始终返回成功	缺少关键资源时返回 503 + missing 列表	poster/routes.py
10	短密钥掩码泄露原值	≤4 字符返回 ****	ppt_admin_service.py
11	设置无键名白名单	添加 _ALLOWED_SETTING_KEYS 白名单	ppt_admin_service.py
12	容器重启任务永久 stuck	添加 recover_stale_tasks() 启动恢复函数	poster/tasks.py, ppt/parse_worker.py
2026-07-27 13:52:09 +08:00
67b2dac23f slidesConfig 结构错误 — migrate_017 输出改为数组格式,migrate_019 修复历史数据
迁移系统加固 — 加 advisory lock 防并发,失败回滚并中止启动(原来是 catch-and-continue)
安全漏洞 — Settings/History API 权限收紧,API key 返回掩码值,海报 case 所有权校验
依赖缺失 — requirements.txt 补齐 python-pptx/openai/Pillow,Dockerfile 改为统一安装
海报鉴权下载 — 前端全部改用 authenticated blob,不再 window.open 无 token URL
LLM 配置分离 — 海报文案读取 poster_llm_*(不再复用 ppt_llm_*),支持 config namespace
图片生成器 — 兼容 b64_json 和 URL 两种响应格式,追踪 generation_mode/provider/model
种子数据 — 新环境自动获得 2 个海报模板 + 2 个文案模板
2026-07-27 13:21:34 +08:00
dbe2f9202d feat: support direct LLM provider config with model sync
- Fix _call_provider to support custom providers (OpenAI-compatible
  fallback) instead of raising ValueError for unknown providers
- Add POST /admin/ppt/sync-models endpoint that fetches available
  models from the configured provider's API
- Redesign PptSettingsAdmin UI: replace Dify model dropdown with
  per-provider 'sync models' button + searchable model selector
- Remove dead Dify-specific code (fetchDifyModels, applyDifyModel)
- Update deepseek default model from deepseek-chat to deepseek-v4-pro
- API Key field now always shown (not conditional on non-dify)
2026-07-25 13:45:32 +08:00
1debd7df39 feat(ppt): upgrade renderer from 5 fixed slides to 10+ configurable pages
Rewrite fast_pptx_renderer.py to read requiredPageTypes from template
config instead of hardcoding 5 slides. Add 10 slide builder functions
(cover, company, narrative, chart, timeline, table, compare, synergy,
conclusion, closing) with python-pptx native charts.

Key changes:
- Renderer reads templateConfig.requiredPageTypes and slidesConfig
  from DeckContract to determine slide sequence and per-slide metadata
- routes.py loads PptTemplate and PptCompany from DB, normalizes all
  PDF extractions (not just the first), passes full context to renderer
- renderer.py injects templateConfig, company info, and multi-product
  data into DeckContract
- Add slides_config_json column to PptTemplate (migrate_017) for
  per-slide title/narrative/chartType configuration via admin UI
- Admin template editor now supports drag-reorder slides, per-slide
  title/narrative hint, chart/table type selection
- Add requiredPageTypes to savings/ink, savings/minimal, savings/business
  templates (were missing, causing fallback to defaults)
- Fix IUL normalizer: add payYears and totalPremium to policy dict
- Fix CI/IUL normalizer: add totalSurrenderValue alias to benefitRows
  so charts render correctly for all product types
- Port calculation functions from baodanppt: decade_rows, paid_premium,
  simple_return, compound_return, find_payback_year

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 17:49:09 +08:00
02e299682e feat: support configurable image generation models for poster creation
- Expand poster image model settings with provider, model name, API key,
  and base URL fields (was only model name + API key)
- Add presets for OpenAI (gpt-image-1), Doubao (火山引擎), and Zhipu (CogView)
- Refactor image_generator.py to read config from system_settings DB instead
  of hardcoding gpt-image-1 and OPENAI_API_KEY env var
- All OpenAI-compatible image APIs work via configurable base URL
- Add doubao and cogview to brand name mapping

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 16:11:37 +08:00
13f7623cb5 fix: infer model brand name from model prefix instead of provider identifier
All Dify models use openai_api_compatible as provider_name, causing
the frontend to display 'openai_api_compatible' for every model.
Now infers brand (DeepSeek, OpenAI, Google, etc.) from model name
prefix to match Dify admin panel display.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 15:59:22 +08:00
53346c9def fix: query Dify DB directly for available models instead of API call
- Replace API-based model fetching with direct SQL query on
  provider_models table (shared PostgreSQL, no auth needed)
- Frontend: auto-detect base_url from model name when selecting
  a Dify model, set provider to 'custom'
- Remove unused requests import and API key fallback logic

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 14:20:34 +08:00
6d571f56a8 fix: auto-fetch Dify models using existing API keys as fallback
- Backend: try DIFY_CHAT/WORKFLOW_API_KEY when workspace key is missing
- Frontend: always show '从 Dify 获取' button, not just after first fetch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:48:37 +08:00
c8e0c0bb1e feat: add model configuration for PPT and poster generation
- PptSettingsAdmin.vue: full settings page with provider/model/API key
  config for PPT extraction, poster copy, and poster image generation
- Backend: GET /insurance/admin/ppt/available-models to fetch models
  from Dify API (falls back to builtin list when unavailable)
- LLM client: read model config from SystemSetting DB with 60s cache,
  priority: database > environment variables > defaults
- ppt-admin-api.ts: add getAvailableModels() method

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:46:04 +08:00
effc2a24e4 0723 PPT加海报功能01版本修复 2026-07-23 17:40:12 +08:00
5d28e4518e 0723 PPT加海报功能初步完成 2026-07-23 15:04:16 +08:00