Add voice_message_prompt tool to API and UI components. Update DuplexPipeline, Assistants, and DebugDrawer to support new tool functionality, including parameter validation and speech synthesis integration. Ensure existing tools are preserved during seeding process in the database.
This commit is contained in:
@@ -87,6 +87,17 @@ TOOL_REGISTRY = {
|
||||
"required": []
|
||||
}
|
||||
},
|
||||
"voice_message_prompt": {
|
||||
"name": "语音消息提示",
|
||||
"description": "播报一条语音提示消息",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msg": {"type": "string", "description": "要播报的消息文本"}
|
||||
},
|
||||
"required": ["msg"]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
TOOL_CATEGORY_MAP = {
|
||||
@@ -97,6 +108,7 @@ TOOL_CATEGORY_MAP = {
|
||||
"turn_off_camera": "system",
|
||||
"increase_volume": "system",
|
||||
"decrease_volume": "system",
|
||||
"voice_message_prompt": "system",
|
||||
}
|
||||
|
||||
TOOL_ICON_MAP = {
|
||||
@@ -107,6 +119,7 @@ TOOL_ICON_MAP = {
|
||||
"turn_off_camera": "CameraOff",
|
||||
"increase_volume": "Volume2",
|
||||
"decrease_volume": "Volume2",
|
||||
"voice_message_prompt": "Volume2",
|
||||
}
|
||||
|
||||
TOOL_HTTP_DEFAULTS = {
|
||||
@@ -185,11 +198,16 @@ def _validate_query_http_config(*, category: str, tool_id: Optional[str], http_u
|
||||
|
||||
|
||||
def _seed_default_tools_if_empty(db: Session) -> None:
|
||||
"""Seed built-in tools only when tool_resources is empty."""
|
||||
"""Ensure built-in tools exist in tool_resources without overriding custom edits."""
|
||||
_ensure_tool_resource_schema(db)
|
||||
if db.query(ToolResource).count() > 0:
|
||||
return
|
||||
existing_ids = {
|
||||
str(item[0])
|
||||
for item in db.query(ToolResource.id).all()
|
||||
}
|
||||
changed = False
|
||||
for tool_id, payload in TOOL_REGISTRY.items():
|
||||
if tool_id in existing_ids:
|
||||
continue
|
||||
http_defaults = TOOL_HTTP_DEFAULTS.get(tool_id, {})
|
||||
db.add(ToolResource(
|
||||
id=tool_id,
|
||||
@@ -207,7 +225,9 @@ def _seed_default_tools_if_empty(db: Session) -> None:
|
||||
enabled=True,
|
||||
is_system=True,
|
||||
))
|
||||
db.commit()
|
||||
changed = True
|
||||
if changed:
|
||||
db.commit()
|
||||
|
||||
|
||||
def recreate_tool_resources(db: Session) -> None:
|
||||
|
||||
Reference in New Issue
Block a user