fix: load api_config before generate_pdf call in export_pdf

This commit is contained in:
hmo
2026-04-27 20:17:20 +08:00
parent c8d77187d1
commit 994e97fec1
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -626,6 +626,10 @@ def export_pdf(plan_id):
except: except:
pass pass
# 获取API配置(水印文本等)
from app.config import load_api_config
api_config = load_api_config(current_app.config)
# 如果有模板,先渲染 # 如果有模板,先渲染
rendered_report = None rendered_report = None
if report_template: if report_template:
@@ -650,6 +654,7 @@ def export_pdf(plan_id):
rendered_report = rendered_report.replace("{ai_report}", "(未生成AI报告)") rendered_report = rendered_report.replace("{ai_report}", "(未生成AI报告)")
problem_tags = "" problem_tags = ""
for problem in content.get('problems', []): for problem in content.get('problems', []):
problem_tags += f"- **{problem.get('name', '')}** ({problem.get('severity', '')})\n" problem_tags += f"- **{problem.get('name', '')}** ({problem.get('severity', '')})\n"
rendered_report = rendered_report.replace("{problem_tags}", problem_tags or "(无)") rendered_report = rendered_report.replace("{problem_tags}", problem_tags or "(无)")
+1 -1
View File
@@ -6,7 +6,7 @@
"provider": "minimax", "provider": "minimax",
"base_url": "https://api.minimaxi.com/anthropic/v1", "base_url": "https://api.minimaxi.com/anthropic/v1",
"model": "MiniMax-M2.7-highspeed", "model": "MiniMax-M2.7-highspeed",
"temperature": 0.3, "temperature": 0.1,
"prompt_template": "", "prompt_template": "",
"api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA" "api_key": "sk-cp-Mj6FHASGAcdc1IhpetY7z4lXCgbkoGAkMbViODPHiVdC-NerbqKRW8ZTCuFliDA9JukoB56ILEYUhDKH2QUJq-xt1ZYNStQ-HNgjRvXIq0H4gOgoxy26xuA"
} }