feat(file-summary): 接入文件汇总工作流触发
This commit is contained in:
30
review_agent/file_summary/workflow_trigger.py
Normal file
30
review_agent/file_summary/workflow_trigger.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from review_agent.models import Conversation, FileAttachment
|
||||
|
||||
|
||||
TRIGGER_KEYWORDS = ("自动汇总", "文件目录", "页数", "目录与页数", "文件清单")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TriggerResult:
|
||||
should_start: bool
|
||||
workflow_type: str = ""
|
||||
reason: str = ""
|
||||
|
||||
|
||||
def evaluate_file_summary_trigger(conversation: Conversation, content: str) -> TriggerResult:
|
||||
text = (content or "").strip()
|
||||
if not any(keyword in text for keyword in TRIGGER_KEYWORDS):
|
||||
return TriggerResult(should_start=False, reason="not_matched")
|
||||
|
||||
has_attachment = FileAttachment.objects.filter(
|
||||
conversation=conversation,
|
||||
is_active=True,
|
||||
).exclude(upload_status=FileAttachment.UploadStatus.DELETED).exists()
|
||||
if not has_attachment:
|
||||
return TriggerResult(should_start=False, reason="missing_attachment")
|
||||
|
||||
return TriggerResult(should_start=True, workflow_type="file_summary")
|
||||
Reference in New Issue
Block a user