feat: add prompt startup actions and shared vision config

This commit is contained in:
Xin Wang
2026-08-01 23:31:14 +08:00
parent b747144ff1
commit 0331f8cd07
22 changed files with 1238 additions and 344 deletions

View File

@@ -92,6 +92,26 @@ ALLOWED_FIELDS: dict[str, set[str]] = {
}
class StartupAction(CamelModel):
id: str = Field(min_length=1, max_length=64, pattern=r"^[A-Za-z][A-Za-z0-9_-]*$")
phase: Literal["preflight", "opening"] = "opening"
tool_id: str = Field(min_length=1, max_length=40)
arguments: dict[str, Any] = Field(default_factory=dict)
required: bool = True
class StartupConfig(CamelModel):
execution_mode: Literal["sequential"] = "sequential"
actions: list[StartupAction] = Field(default_factory=list, max_length=5)
@model_validator(mode="after")
def validate_unique_action_ids(self):
ids = [action.id for action in self.actions]
if len(ids) != len(set(ids)):
raise ValueError("启动 Action 的 id 不能重复")
return self
# ---------- 助手(单表 STI:瘦类型真列 + workflow 图 JSON 列) ----------
class AssistantUpsert(CamelModel):
name: str
@@ -100,6 +120,7 @@ class AssistantUpsert(CamelModel):
greeting: str = ""
enable_interrupt: bool = True
turn_config: TurnConfig = Field(default_factory=TurnConfig)
startup: StartupConfig = Field(default_factory=StartupConfig)
vision_enabled: bool = False
vision_model_resource_id: str | None = None
@@ -145,6 +166,10 @@ class AssistantUpsert(CamelModel):
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")
# 外部托管大脑只能 cascade,拦住不兼容的 realtime
if self.runtime_mode == "realtime" and self.type not in REALTIME_CAPABLE_TYPES:
raise ValueError(f"类型 {self.type} 不支持 realtime 运行模式")