Commit Graph

30 Commits

Author SHA1 Message Date
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
a4d458c978 fix: map unsupported themes to renderer-compatible themes
- Map broker/modern/fresh to deepblue
- Map warm to caramel
- Keep chinese as is
- Fix 'invalid choice: broker' error
2026-07-24 16:55:09 +08:00
0c9975ed3a fix: correct parameter name in add_textbox call
- Change font_size to size in customer name textbox
- Fix 'unexpected keyword argument' error in renderer
2026-07-24 16:51:42 +08:00
071f08d84a fix: use current Python interpreter for subprocess
- Prefer sys.executable for subprocess calls
- Add fallback to virtual environment Python
- Fix 'No module named pptx' error in Docker
2026-07-24 16:46:12 +08:00
91579d54a0 fix: pass pdf_path to normalizer for data provenance
- Add pdfPath to extraction results in parse_session
- Pass pdf_path to normalizer functions in generate_ppt
- Fix 'missing PDF hash' validation error
2026-07-24 16:41:45 +08:00
eef8fc0892 fix: support multiple PDF parsers for PPT extraction
- Add compatibility for PyMuPDF versions (fitz and pymupdf imports)
- Add fallback support for PyPDF2, pypdf, and pdfplumber
- Update requirements.txt with PDF parsing dependencies
- Fix 'cannot extract PDF text' error in Docker environment
2026-07-24 16:36:52 +08:00
3a0f4f6830 feat: support Dify-synced models without separate API key
When a model is selected from Dify, set provider='dify' and call
through Dify Chat API (/v1/chat-messages) using the existing
DIFY_CHAT_APP_API_KEY. No separate API key configuration needed.

- Frontend: hide API Key/Base URL fields when provider is 'dify',
  show 'via Dify, no API key needed' tag
- Backend: add _call_dify() to route through Dify Chat API
- Backend: _try_load_db_config supports dify provider without api_key

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 16:18:59 +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
cecf908153 fix: correct response data path for Dify models and settings API
The axios interceptor already returns response.data, so accessing
res.data.data was one level too deep, causing the models list to
always be empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 15:23:45 +08:00
7a53834f5d fix: use localhost for BaoDan admin URL in local dev
Replace hardcoded server IP 150.5.135.143 with localhost in
openDifyAdmin() to match local development environment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 14:38:52 +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
6c3343a222 fix: accept cached extractions in generate/validate and improve parse error UX
- generate_ppt and validate_extraction now accept status 'cached'
  alongside 'success', matching the frontend's hasSuccess logic
- PptParsing: show extraction error messages in the results table
- PptParsing: show '解析失败' icon when all extractions fail
- PptParsing: only show '下一步' button when at least one extraction succeeded
- routes.py: add error logging with stack trace in parse endpoint

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:05:27 +08:00
c8832ae50c fix: add missing progressStatus computed in PptParsing.vue
progressStatus was referenced in the template but never defined,
causing a Vue runtime warning on every render.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 12:57:33 +08:00
8b4988b0d5 fix: add api/ to sys.path so app.py can run from project root
Also resolve .env.local and .env paths relative to project root
instead of current working directory.
2026-07-24 12:39:57 +08:00
622f0d18b2 fix: replace Chinese comments in requirements.txt with English to fix pip decode error on Windows
pip on Windows uses GBK codec by default and fails on UTF-8 Chinese
characters in requirements.txt.
2026-07-24 12:36:09 +08:00
0fbf6f534c fix: restore corrupted Chinese comments and add .env.local support for local dev
- Restore proper UTF-8 Chinese comments (effc2a24 introduced mojibake
  via double-encoding: UTF-8 → GBK → Latin-1 → UTF-8)
- Remove spurious BOM header
- Load .env.local with override=True before .env so local dev config
  (localhost:5433 for PostgreSQL, localhost:6380 for Redis) takes
  priority without affecting Docker deployments
2026-07-24 12:32:26 +08:00
623815a134 fix: 添加 PyMuPDF 详细错误信息并创建缺失的迁移文件
- extraction.py: 添加更详细的 ImportError 错误信息,显示具体原因
- migrate_016.py: 创建 insurance_ppt_sessions 表(修复 500 错误)

解决 PDF 上传失败问题:
1. PyMuPDF 导入失败时显示具体错误原因
2. 数据库表 insurance_ppt_sessions 不存在导致插入失败

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 11:29:49 +08:00
6eded843a7 0723 PPT加海报功能01版本修复-数据可以正常加载 2026-07-23 21:32:38 +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
4a556a1cc7 0723 PPT功能初步融合 2026-07-23 13:10:50 +08:00
33b869e59d 0723 添加baodanppt项目 2026-07-23 09:18:16 +08:00
c32efbaed9 0723 代码整理 2026-07-23 08:52:59 +08:00
01ebaeb57c 0723 整理文件 2026-07-23 08:38:11 +08:00
8253867913 0712 提交一个版本 2026-07-22 18:09:03 +08:00
d0a887d5c2 0712 修复一个版本 2026-07-12 14:17:18 +08:00
bc4c339e0c 第一次提交。可以使用企微群消息 2026-07-02 23:13:23 +08:00