refactor: unify system tools as resources
This commit is contained in:
@@ -159,9 +159,6 @@ class AssistantUpsert(CamelModel):
|
||||
startup: StartupConfig = Field(default_factory=StartupConfig)
|
||||
vision_enabled: bool = False
|
||||
vision_model_resource_id: str | None = None
|
||||
# 内置系统工具开关(仅 prompt 类型可用,类似 ElevenLabs Agent 的系统工具)。
|
||||
system_tools: list[SystemToolKind] = Field(default_factory=list, max_length=4)
|
||||
|
||||
model_resource_ids: dict[ModelType, str] = Field(default_factory=dict)
|
||||
knowledge_base_id: str | None = None
|
||||
knowledge_retrieval_config: KnowledgeRetrievalConfig = Field(
|
||||
@@ -199,8 +196,6 @@ class AssistantUpsert(CamelModel):
|
||||
for field in ("prompt", "api_url", "api_key", "app_id"):
|
||||
if field not in allowed:
|
||||
setattr(self, field, "")
|
||||
if self.type != "prompt":
|
||||
self.system_tools = []
|
||||
if "graph" not in allowed:
|
||||
self.graph = {}
|
||||
if self.type == "workflow":
|
||||
@@ -220,15 +215,6 @@ class AssistantUpsert(CamelModel):
|
||||
# 外部托管大脑只能 cascade,拦住不兼容的 realtime
|
||||
if self.runtime_mode == "realtime" and self.type not in REALTIME_CAPABLE_TYPES:
|
||||
raise ValueError(f"类型 {self.type} 不支持 realtime 运行模式")
|
||||
if self.type == "prompt":
|
||||
self.system_tools = list(dict.fromkeys(self.system_tools))
|
||||
if self.runtime_mode == "realtime" and self.system_tools:
|
||||
raise ValueError("Prompt Realtime 模式暂不支持系统工具")
|
||||
if (
|
||||
"update_state" in self.system_tools
|
||||
and not self.dynamic_variable_definitions
|
||||
):
|
||||
raise ValueError("启用更新状态工具前必须声明至少一个动态变量")
|
||||
return self
|
||||
|
||||
|
||||
@@ -270,7 +256,7 @@ class ToolParameter(CamelModel):
|
||||
|
||||
|
||||
class SystemToolConfig(CamelModel):
|
||||
kind: Literal["end_conversation"] = "end_conversation"
|
||||
kind: SystemToolKind = "end_conversation"
|
||||
message_type: Literal["none", "custom"] = "none"
|
||||
custom_message: str = ""
|
||||
capture_reason: bool = True
|
||||
|
||||
Reference in New Issue
Block a user