feat: add configurable client tools and photo input
This commit is contained in:
@@ -19,12 +19,13 @@ ModelType = Literal["LLM", "ASR", "TTS", "Realtime", "Embedding", "Agent"]
|
||||
AssistantType = Literal["prompt", "workflow", "dify", "fastgpt", "opencode"]
|
||||
TurnEndStrategy = Literal["silence", "smart_turn"]
|
||||
KnowledgeRetrievalMode = Literal["automatic", "on_demand"]
|
||||
ToolType = Literal["end_call", "http", "mcp"]
|
||||
ToolType = Literal["end_call", "http", "mcp", "client"]
|
||||
ToolStatus = Literal["active", "archived", "draft"]
|
||||
McpServerStatus = Literal["active", "archived", "draft"]
|
||||
McpTransport = Literal["streamable_http", "sse"]
|
||||
ToolParameterType = Literal["string", "number", "integer", "boolean", "object", "array"]
|
||||
ToolParameterLocation = Literal["path", "query", "body", "header"]
|
||||
ToolExecutionMode = Literal["immediate", "async"]
|
||||
DynamicVariableType = Literal["string", "number", "boolean"]
|
||||
|
||||
# 外部应用类型:其 config.apiKey 是该助手私有密钥,读时打码 / 写时哨兵
|
||||
@@ -193,6 +194,8 @@ class EndCallToolConfig(CamelModel):
|
||||
|
||||
|
||||
class HttpToolConfig(CamelModel):
|
||||
allow_interruptions: bool = True
|
||||
execution_mode: ToolExecutionMode = "immediate"
|
||||
method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"] = "GET"
|
||||
url: str
|
||||
timeout_seconds: int = Field(default=15, ge=1, le=120)
|
||||
@@ -221,7 +224,30 @@ class HttpToolDefinition(CamelModel):
|
||||
config: HttpToolConfig
|
||||
|
||||
|
||||
class ClientToolConfig(CamelModel):
|
||||
allow_interruptions: bool = True
|
||||
execution_mode: ToolExecutionMode = "async"
|
||||
wait_for_response: bool = True
|
||||
parameters: list[ToolParameter] = Field(default_factory=list)
|
||||
timeout_seconds: int = Field(default=3, ge=1, le=30)
|
||||
dynamic_variable_assignments: dict[str, str] = Field(default_factory=dict)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_result_assignments(self):
|
||||
if not self.wait_for_response and self.dynamic_variable_assignments:
|
||||
raise ValueError("Client Tool 不等待响应时不能配置结果变量赋值")
|
||||
return self
|
||||
|
||||
|
||||
class ClientToolDefinition(CamelModel):
|
||||
schema_version: int = 1
|
||||
type: Literal["client"] = "client"
|
||||
config: ClientToolConfig = Field(default_factory=ClientToolConfig)
|
||||
|
||||
|
||||
class McpToolConfig(CamelModel):
|
||||
allow_interruptions: bool = True
|
||||
execution_mode: ToolExecutionMode = "immediate"
|
||||
remote_tool_name: str = Field(min_length=1, max_length=255)
|
||||
input_schema: dict[str, Any] = Field(default_factory=dict)
|
||||
schema_hash: str = ""
|
||||
@@ -235,7 +261,12 @@ class McpToolDefinition(CamelModel):
|
||||
|
||||
|
||||
ToolDefinition = Annotated[
|
||||
Union[EndCallToolDefinition, HttpToolDefinition, McpToolDefinition],
|
||||
Union[
|
||||
EndCallToolDefinition,
|
||||
HttpToolDefinition,
|
||||
ClientToolDefinition,
|
||||
McpToolDefinition,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user