feat(regulatory-info-package): 接入对话和前端卡片
This commit is contained in:
@@ -16,7 +16,15 @@ from .services import (
|
||||
send_message,
|
||||
stream_message,
|
||||
)
|
||||
from .models import ApplicationFormFillBatch, Conversation, FileAttachment, FileSummaryBatch, RegulatoryReviewBatch, WorkflowNodeRun
|
||||
from .models import (
|
||||
ApplicationFormFillBatch,
|
||||
Conversation,
|
||||
FileAttachment,
|
||||
FileSummaryBatch,
|
||||
RegulatoryInfoPackageBatch,
|
||||
RegulatoryReviewBatch,
|
||||
WorkflowNodeRun,
|
||||
)
|
||||
from .knowledge_base import build_knowledge_base_context, search_knowledge_base
|
||||
from .knowledge_base import (
|
||||
build_knowledge_base_context_for_user,
|
||||
@@ -329,6 +337,25 @@ def build_workflow_cards(conversation: Conversation) -> list[dict[str, object]]:
|
||||
),
|
||||
}
|
||||
)
|
||||
rip_batches = RegulatoryInfoPackageBatch.objects.filter(conversation=conversation, is_deleted=False)
|
||||
for batch in rip_batches:
|
||||
cards.append(
|
||||
{
|
||||
"id": batch.pk,
|
||||
"workflow_type": "regulatory_info_package",
|
||||
"batch_no": batch.batch_no,
|
||||
"status": batch.status,
|
||||
"error_message": batch.error_message,
|
||||
"risk_label": _format_regulatory_info_package_label(batch),
|
||||
"created_at": batch.created_at,
|
||||
"nodes": list(
|
||||
WorkflowNodeRun.objects.filter(
|
||||
workflow_type="regulatory_info_package",
|
||||
workflow_batch_id=batch.pk,
|
||||
).order_by("id")
|
||||
),
|
||||
}
|
||||
)
|
||||
return sorted(cards, key=lambda item: item["created_at"], reverse=True)[:5]
|
||||
|
||||
|
||||
@@ -374,6 +401,20 @@ def _format_form_fill_label(batch: ApplicationFormFillBatch) -> str:
|
||||
return " · ".join(parts)
|
||||
|
||||
|
||||
def _format_regulatory_info_package_label(batch: RegulatoryInfoPackageBatch) -> str:
|
||||
parts = []
|
||||
if batch.product_name:
|
||||
parts.append(batch.product_name)
|
||||
if batch.generated_files:
|
||||
success_count = sum(1 for item in batch.generated_files if item.get("status") in {"success", "fallback_success"})
|
||||
parts.append(f"生成 {success_count}/7")
|
||||
if batch.missing_fields:
|
||||
parts.append(f"缺失 {len(batch.missing_fields)}")
|
||||
if batch.conflict_fields:
|
||||
parts.append(f"冲突 {len(batch.conflict_fields)}")
|
||||
return " · ".join(parts)
|
||||
|
||||
|
||||
def build_home_dashboard_context(user) -> dict[str, object]:
|
||||
conversations = Conversation.objects.filter(user=user)
|
||||
active_attachments = FileAttachment.objects.filter(user=user).exclude(
|
||||
|
||||
Reference in New Issue
Block a user