feat: add deterministic message interaction stages

This commit is contained in:
Xin Wang
2026-08-03 07:10:41 +08:00
parent 479a516546
commit 9daa46ed4d
26 changed files with 1356 additions and 414 deletions

View File

@@ -100,9 +100,18 @@ class StartupAction(CamelModel):
required: bool = True
class OpeningMessageConfig(CamelModel):
"""Built-in Prompt opening interaction; it is not a reusable LLM tool."""
title: str = Field(default="重要提示", min_length=1, max_length=120)
message: str = Field(min_length=1, max_length=2000)
confirm_label: str = Field(default="确认", min_length=1, max_length=40)
class StartupConfig(CamelModel):
execution_mode: Literal["sequential"] = "sequential"
actions: list[StartupAction] = Field(default_factory=list, max_length=5)
opening_message: OpeningMessageConfig | None = None
@model_validator(mode="after")
def validate_unique_action_ids(self):
@@ -163,13 +172,17 @@ class AssistantUpsert(CamelModel):
setattr(self, field, "")
if "graph" not in allowed:
self.graph = {}
if self.type == "workflow":
self.greeting = ""
if self.type not in {"prompt", "workflow"}:
self.tool_ids = []
self.dynamic_variable_definitions = {}
if self.type != "prompt":
self.startup = StartupConfig()
if self.runtime_mode == "realtime" and self.startup.actions:
raise ValueError("Prompt Realtime 模式暂不支持启动 Action")
if self.runtime_mode == "realtime" and (
self.startup.actions or self.startup.opening_message is not None
):
raise ValueError("Prompt Realtime 模式暂不支持启动阶段")
# 外部托管大脑只能 cascade,拦住不兼容的 realtime
if self.runtime_mode == "realtime" and self.type not in REALTIME_CAPABLE_TYPES:
raise ValueError(f"类型 {self.type} 不支持 realtime 运行模式")