feat: separate prompt opening and entry behavior
This commit is contained in:
@@ -28,6 +28,7 @@ ToolParameterLocation = Literal["path", "query", "body", "header"]
|
||||
ToolExecutionMode = Literal["immediate", "async"]
|
||||
ClientToolResponseWaitMode = Literal["timeout", "session"]
|
||||
DynamicVariableType = Literal["string", "number", "boolean"]
|
||||
PromptEntryMode = Literal["wait_user", "generate"]
|
||||
|
||||
# 外部应用类型:其 config.apiKey 是该助手私有密钥,读时打码 / 写时哨兵
|
||||
EXTERNAL_TYPES = {"dify", "fastgpt", "opencode"}
|
||||
@@ -106,10 +107,12 @@ class OpeningMessageConfig(CamelModel):
|
||||
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)
|
||||
skip_speech_on_confirm: bool = True
|
||||
|
||||
|
||||
class StartupConfig(CamelModel):
|
||||
execution_mode: Literal["sequential"] = "sequential"
|
||||
entry_mode: PromptEntryMode | None = None
|
||||
actions: list[StartupAction] = Field(default_factory=list, max_length=5)
|
||||
opening_message: OpeningMessageConfig | None = None
|
||||
|
||||
@@ -118,6 +121,12 @@ class StartupConfig(CamelModel):
|
||||
ids = [action.id for action in self.actions]
|
||||
if len(ids) != len(set(ids)):
|
||||
raise ValueError("启动 Action 的 id 不能重复")
|
||||
if self.entry_mode is None:
|
||||
# Preserve the behavior introduced before entryMode became an
|
||||
# explicit setting. Newly saved clients always send the field.
|
||||
self.entry_mode = (
|
||||
"generate" if self.opening_message is not None else "wait_user"
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
@@ -180,7 +189,9 @@ class AssistantUpsert(CamelModel):
|
||||
if self.type != "prompt":
|
||||
self.startup = StartupConfig()
|
||||
if self.runtime_mode == "realtime" and (
|
||||
self.startup.actions or self.startup.opening_message is not None
|
||||
self.startup.actions
|
||||
or self.startup.opening_message is not None
|
||||
or self.startup.entry_mode != "wait_user"
|
||||
):
|
||||
raise ValueError("Prompt Realtime 模式暂不支持启动阶段")
|
||||
# 外部托管大脑只能 cascade,拦住不兼容的 realtime
|
||||
|
||||
Reference in New Issue
Block a user