Organize tool scheme
This commit is contained in:
@@ -100,6 +100,23 @@ def init_default_data():
|
||||
db.close()
|
||||
|
||||
|
||||
def init_default_tools(recreate: bool = False):
|
||||
"""初始化默认工具,或按需重建工具表数据。"""
|
||||
from app.db import SessionLocal
|
||||
from app.routers.tools import _seed_default_tools_if_empty, recreate_tool_resources
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
if recreate:
|
||||
recreate_tool_resources(db)
|
||||
print("✅ 工具库已重建")
|
||||
else:
|
||||
_seed_default_tools_if_empty(db)
|
||||
print("✅ 默认工具已初始化")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def init_default_assistants():
|
||||
"""初始化默认助手"""
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -121,7 +138,7 @@ def init_default_assistants():
|
||||
voice="anna",
|
||||
speed=1.0,
|
||||
hotwords=[],
|
||||
tools=["search", "calculator"],
|
||||
tools=["calculator", "current_time"],
|
||||
interruption_sensitivity=500,
|
||||
config_mode="platform",
|
||||
llm_model_id="deepseek-chat",
|
||||
@@ -139,7 +156,7 @@ def init_default_assistants():
|
||||
voice="bella",
|
||||
speed=1.0,
|
||||
hotwords=["客服", "投诉", "咨询"],
|
||||
tools=["search"],
|
||||
tools=["current_time"],
|
||||
interruption_sensitivity=600,
|
||||
config_mode="platform",
|
||||
),
|
||||
@@ -155,7 +172,7 @@ def init_default_assistants():
|
||||
voice="alex",
|
||||
speed=1.0,
|
||||
hotwords=["grammar", "vocabulary", "practice"],
|
||||
tools=[],
|
||||
tools=["calculator"],
|
||||
interruption_sensitivity=400,
|
||||
config_mode="platform",
|
||||
),
|
||||
@@ -421,6 +438,11 @@ if __name__ == "__main__":
|
||||
action="store_true",
|
||||
help="跳过默认数据初始化",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--recreate-tool-db",
|
||||
action="store_true",
|
||||
help="重建工具库数据(清空 tool_resources 后按内置默认工具重建)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# 无参数时保持旧行为:重建 DB + 初始化默认数据
|
||||
@@ -434,8 +456,13 @@ if __name__ == "__main__":
|
||||
if args.rebuild_db:
|
||||
init_db()
|
||||
|
||||
if args.recreate_tool_db:
|
||||
init_default_tools(recreate=True)
|
||||
|
||||
if not args.skip_seed:
|
||||
init_default_data()
|
||||
if not args.recreate_tool_db:
|
||||
init_default_tools(recreate=False)
|
||||
init_default_assistants()
|
||||
init_default_workflows()
|
||||
init_default_knowledge_bases()
|
||||
|
||||
Reference in New Issue
Block a user