34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from django.urls import reverse
|
|
|
|
from review_agent.models import Message
|
|
|
|
from ..services.export_excel import generate_excel_export
|
|
from ..services.report import generate_markdown_report
|
|
from .base import BaseSkill, SkillResult, WorkflowContext
|
|
|
|
|
|
class SummaryReportSkill(BaseSkill):
|
|
name = "summary_report"
|
|
|
|
def run(self, context: WorkflowContext) -> SkillResult:
|
|
markdown_export, summary_table = generate_markdown_report(context.batch)
|
|
excel_export = generate_excel_export(context.batch)
|
|
markdown_url = reverse("file_summary_export_download", args=[markdown_export.pk])
|
|
excel_url = reverse("file_summary_export_download", args=[excel_export.pk])
|
|
content = (
|
|
"文件目录与页数汇总已完成。\n\n"
|
|
f"{summary_table}\n\n"
|
|
f"[下载 Markdown 报告]({markdown_url}) | [下载 Excel 明细]({excel_url})"
|
|
)
|
|
Message.objects.create(
|
|
conversation=context.batch.conversation,
|
|
role=Message.Role.ASSISTANT,
|
|
content=content,
|
|
)
|
|
return SkillResult(
|
|
success=True,
|
|
data={"markdown_export_id": markdown_export.pk, "excel_export_id": excel_export.pk},
|
|
)
|