mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-31 12:24:39 +08:00
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""
|
|
Agent 轻量公共合同,不触发模型、工具或编排运行时加载。
|
|
"""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
from typing import Any, Mapping, Optional, Sequence
|
|
|
|
from app.schemas.types import ReplyMode
|
|
|
|
|
|
def build_display_message(
|
|
role: str,
|
|
content: str = "",
|
|
attachments: Optional[Sequence[Mapping[str, object]]] = None,
|
|
status: str = "done",
|
|
) -> dict[str, Any]:
|
|
"""
|
|
构造前后端共享的 Agent 会话展示消息。
|
|
|
|
附件只读且不复制非空输入,字段值可以保留嵌套展示数据。
|
|
"""
|
|
normalized_content = content or ""
|
|
return {
|
|
"id": f"{role}-{uuid.uuid4().hex}",
|
|
"role": role,
|
|
"content": normalized_content,
|
|
"createdAt": int(datetime.now().timestamp() * 1000),
|
|
"status": status,
|
|
"tools": [],
|
|
"segments": (
|
|
[{"type": "text", "content": normalized_content}]
|
|
if normalized_content
|
|
else []
|
|
),
|
|
"attachments": attachments or [],
|
|
"choices": [],
|
|
}
|
|
|
|
|
|
__all__ = ["ReplyMode", "build_display_message"]
|