27 lines
918 B
Python
27 lines
918 B
Python
from .models import Conversation
|
|
|
|
|
|
def create_conversation_for_batch(batch_id: str, product_name: str) -> Conversation:
|
|
"""
|
|
为资料包创建主会话。
|
|
|
|
会话标题固定优先使用解析出的产品名称,
|
|
缺失时回退到批次号,确保前台始终有稳定标题。
|
|
"""
|
|
conversation = Conversation.objects.create(
|
|
conversation_id=_generate_conversation_id(),
|
|
title=product_name or f"未命名资料包-{batch_id}",
|
|
product_name=product_name,
|
|
batch_id=batch_id,
|
|
task_status=Conversation.STATUS_PENDING,
|
|
node_results=[
|
|
{"code": "package_import", "label": "资料包导入", "status": "已完成"},
|
|
{"code": "overview", "label": "目录汇总", "status": "处理中"},
|
|
],
|
|
)
|
|
return conversation
|
|
|
|
|
|
def _generate_conversation_id() -> str:
|
|
return f"conv-{Conversation.objects.count() + 1:03d}"
|