Refactor assistant configuration and database seeding

- Update Makefile to include new database seed commands for assistants and credentials.
- Refactor assistant model to use explicit fields instead of a config dictionary, improving data integrity and clarity.
- Implement new seeding SQL script for assistants, ensuring dependencies on credentials are respected.
- Modify backend routes and frontend components to accommodate the new assistant structure, including direct field access for prompt, API URL, and keys.
- Enhance the AssistantPage component to handle the new data structure and streamline the save process for different assistant types.
This commit is contained in:
Xin Wang
2026-06-09 10:37:29 +08:00
parent 23e1cf5d42
commit 519cc0fefe
8 changed files with 197 additions and 185 deletions

View File

@@ -48,20 +48,18 @@ async def resolve_runtime_config(
tts = await _resolve(session, assistant.tts_credential_id, "TTS")
realtime = await _resolve(session, assistant.realtime_credential_id, "Realtime")
cfg = assistant.config or {}
return AssistantConfig(
name=assistant.name,
greeting=assistant.greeting,
# 提示词/工作流类型把 prompt 放 config;外部类型由其平台编排,这里给个兜底
prompt=cfg.get("prompt") or "你是一个有帮助的助手。",
# prompt 现在是真列;外部类型由其平台编排,这里给个兜底
prompt=assistant.prompt or "你是一个有帮助的助手。",
runtimeMode=assistant.runtime_mode, # type: ignore[arg-type]
enableInterrupt=assistant.enable_interrupt,
# 模型/音色:凭证的模型ID优先
model=(llm.model_id if llm else ""),
asr=(stt.model_id if stt else ""),
voice=cfg.get("voice", ""), # 音色不再是独立列,若 config 带则用,否则 .env 兜底
realtimeModel=(realtime.model_id if realtime else cfg.get("realtimeModel", "")),
voice="", # 音色独立列,留空 → service_factory 回退 .env TTS_VOICE
realtimeModel=(realtime.model_id if realtime else ""),
# 运行时连接信息(真 key + url):凭证优先,否则 .env 兜底
llm_api_key=(llm.api_key if llm else config.LLM_API_KEY),
llm_base_url=(llm.api_url if llm else config.LLM_BASE_URL),