feat(agent): 增加 LLM 路由与诊断日志

This commit is contained in:
2026-06-06 17:56:41 +08:00
parent 47b5ad1054
commit fa77c68d77
21 changed files with 832 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import logging
from pathlib import Path
from django.conf import settings
@@ -8,6 +9,9 @@ from openpyxl import Workbook
from review_agent.models import ExportedSummaryFile, FileSummaryBatch
logger = logging.getLogger("review_agent.file_summary.export_excel")
def _exports_dir(batch: FileSummaryBatch) -> Path:
root = Path(batch.work_dir) if batch.work_dir else Path(settings.MEDIA_ROOT) / "file_summary" / batch.batch_no
export_dir = root / "exports"
@@ -16,6 +20,7 @@ def _exports_dir(batch: FileSummaryBatch) -> Path:
def generate_excel_export(batch: FileSummaryBatch) -> ExportedSummaryFile:
logger.info("Excel export generation started", extra={"batch_id": batch.pk})
workbook = Workbook()
summary = workbook.active
summary.title = "汇总信息"
@@ -47,9 +52,14 @@ def generate_excel_export(batch: FileSummaryBatch) -> ExportedSummaryFile:
path = _exports_dir(batch) / f"{batch.batch_no}-summary.xlsx"
workbook.save(path)
return ExportedSummaryFile.objects.create(
exported = ExportedSummaryFile.objects.create(
batch=batch,
export_type=ExportedSummaryFile.ExportType.EXCEL,
file_name=path.name,
storage_path=str(path),
)
logger.info(
"Excel export generation finished",
extra={"batch_id": batch.pk, "export_id": exported.pk, "path": str(path)},
)
return exported