refactor: unify system tools as resources
This commit is contained in:
@@ -154,8 +154,6 @@ class Assistant(Base):
|
||||
enable_interrupt: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
turn_config: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
startup: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
# Prompt 助手级系统工具;Workflow 的权限保存在各 Agent 节点中。
|
||||
system_tools: Mapped[list] = mapped_column(JSON, default=list)
|
||||
vision_enabled: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
vision_model_resource_id: Mapped[str | None] = mapped_column(
|
||||
String(40),
|
||||
|
||||
@@ -10,6 +10,7 @@ import json
|
||||
|
||||
import settings
|
||||
from services.interface_catalog import INTERFACE_DEFINITIONS
|
||||
from services.system_tools import SYSTEM_TOOL_SPECS
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import (
|
||||
AsyncSession,
|
||||
@@ -49,24 +50,31 @@ async def sync_interface_definitions() -> None:
|
||||
|
||||
async def sync_default_tools() -> None:
|
||||
"""Ensure system-provided reusable tools exist without overwriting edits."""
|
||||
default_tools = [
|
||||
{
|
||||
"id": "tool_end_call_default",
|
||||
"name": "结束对话",
|
||||
"function_name": "end_call",
|
||||
"type": "system",
|
||||
"description": "当用户明确要求结束对话,或任务已完成时调用。",
|
||||
"definition": {
|
||||
"schema_version": 1,
|
||||
"type": "system",
|
||||
"config": {
|
||||
"kind": "end_conversation",
|
||||
default_system_tools = []
|
||||
for kind, spec in SYSTEM_TOOL_SPECS.items():
|
||||
config: dict[str, object] = {"kind": kind}
|
||||
if kind == "end_conversation":
|
||||
config.update(
|
||||
{
|
||||
"message_type": "none",
|
||||
"custom_message": "",
|
||||
"capture_reason": True,
|
||||
}
|
||||
)
|
||||
default_system_tools.append(
|
||||
{
|
||||
**spec,
|
||||
"type": "system",
|
||||
"definition": {
|
||||
"schema_version": 1,
|
||||
"type": "system",
|
||||
"config": config,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
default_tools = [
|
||||
*default_system_tools,
|
||||
{
|
||||
"id": "tool_show_message_default",
|
||||
"name": "显示确认消息",
|
||||
|
||||
Reference in New Issue
Block a user