feat(regulatory-info-package): 接入对话和前端卡片
This commit is contained in:
@@ -19,6 +19,12 @@ from .application_form_fill.workflow import (
|
||||
find_latest_successful_summary_batch as find_latest_successful_form_fill_summary_batch,
|
||||
start_application_form_fill_workflow,
|
||||
)
|
||||
from .regulatory_info_package.constants import WORKFLOW_TYPE as REGULATORY_INFO_PACKAGE_WORKFLOW_TYPE
|
||||
from .regulatory_info_package.services.input_select import select_instruction_input
|
||||
from .regulatory_info_package.workflow import (
|
||||
create_regulatory_info_package_batch,
|
||||
start_regulatory_info_package_workflow,
|
||||
)
|
||||
from .regulatory_review.workflow import (
|
||||
create_regulatory_review_batch,
|
||||
find_latest_successful_summary_batch,
|
||||
@@ -342,6 +348,56 @@ def stream_message(conversation: Conversation, content: str):
|
||||
)
|
||||
return
|
||||
|
||||
if route.starts_regulatory_info_package:
|
||||
selection = select_instruction_input(conversation, content)
|
||||
if selection.status != "selected":
|
||||
reply_content = selection.message or "请先在当前对话右侧上传产品说明书 docx 文件,然后再发送第1章监管信息生成指令。"
|
||||
assistant_message = append_assistant_message(conversation, reply_content)
|
||||
yield sse_event("chunk", {"delta": reply_content})
|
||||
yield sse_event(
|
||||
"done",
|
||||
{
|
||||
"assistant_message_id": assistant_message.pk,
|
||||
"conversation_id": conversation.pk,
|
||||
"title": conversation.title,
|
||||
},
|
||||
)
|
||||
return
|
||||
batch = create_regulatory_info_package_batch(
|
||||
conversation=conversation,
|
||||
user=conversation.user,
|
||||
trigger_message=user_message,
|
||||
source_attachment=selection.attachment,
|
||||
source_summary_batch=selection.source_summary_batch,
|
||||
source_summary_item_id=selection.source_summary_item_id,
|
||||
source_file_name=selection.file_name,
|
||||
source_storage_path=selection.storage_path,
|
||||
)
|
||||
start_regulatory_info_package_workflow(
|
||||
batch,
|
||||
async_run=getattr(settings, "REGULATORY_INFO_PACKAGE_ASYNC", True),
|
||||
)
|
||||
reply_content = f"已启动第1章监管信息材料包生成工作流,批次号:{batch.batch_no}。"
|
||||
assistant_message = append_assistant_message(conversation, reply_content)
|
||||
yield sse_event(
|
||||
"workflow_started",
|
||||
{
|
||||
"workflow_type": REGULATORY_INFO_PACKAGE_WORKFLOW_TYPE,
|
||||
"batch_id": batch.pk,
|
||||
"batch_no": batch.batch_no,
|
||||
},
|
||||
)
|
||||
yield sse_event("chunk", {"delta": reply_content})
|
||||
yield sse_event(
|
||||
"done",
|
||||
{
|
||||
"assistant_message_id": assistant_message.pk,
|
||||
"conversation_id": conversation.pk,
|
||||
"title": conversation.title,
|
||||
},
|
||||
)
|
||||
return
|
||||
|
||||
if route.starts_regulatory_review:
|
||||
source_summary_batch = find_latest_successful_summary_batch(conversation)
|
||||
if not source_summary_batch:
|
||||
|
||||
Reference in New Issue
Block a user