feat(attachments): 增加附件阅读解析能力
This commit is contained in:
@@ -6,6 +6,19 @@ from review_agent.models import Conversation, FileAttachment
|
||||
|
||||
|
||||
TRIGGER_KEYWORDS = ("自动汇总", "文件目录", "页数", "目录与页数", "文件清单")
|
||||
ATTACHMENT_READER_KEYWORDS = (
|
||||
"阅读附件",
|
||||
"读取附件",
|
||||
"解析附件",
|
||||
"分析附件",
|
||||
"查看附件",
|
||||
"附件详情",
|
||||
"文件详情",
|
||||
"总结附件",
|
||||
"总结文件",
|
||||
"分析这个文件",
|
||||
"阅读这个文件",
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -28,3 +41,18 @@ def evaluate_file_summary_trigger(conversation: Conversation, content: str) -> T
|
||||
return TriggerResult(should_start=False, reason="missing_attachment")
|
||||
|
||||
return TriggerResult(should_start=True, workflow_type="file_summary")
|
||||
|
||||
|
||||
def evaluate_attachment_reader_trigger(conversation: Conversation, content: str) -> TriggerResult:
|
||||
text = (content or "").strip()
|
||||
if not any(keyword in text for keyword in ATTACHMENT_READER_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="attachment_reader")
|
||||
|
||||
Reference in New Issue
Block a user