-- 知识库 + 助手种子数据。依赖 seed_model_resources.sql。

INSERT INTO knowledge_bases
  (id, name, description, embedding_model_resource_id, status)
VALUES
  ('kb_001', '政务政策知识库', '政策解读 / 办事指南示例库', 'model_003', 'active')
ON CONFLICT (id) DO NOTHING;

INSERT INTO assistants (
  id, name, type, runtime_mode, greeting, enable_interrupt,
  knowledge_base_id, prompt, api_url, api_key, app_id, graph
) VALUES
  ('asst_001', '政务咨询助手', 'prompt', 'pipeline', '您好，我是政务助手，请问有什么可以帮您？', TRUE,
   'kb_001', '你是一名专业的政务咨询助手，回答准确、简洁，不编造政策内容。', '', '', '', '{}'),
  ('asst_002', '热线工单助手', 'workflow', 'pipeline', '', TRUE,
   NULL, '', '', '', '',
   '{"nodes":[{"id":"1","type":"startCall","position":{"x":0,"y":0},"data":{"name":"开场","prompt":"你好，请问需要办理什么业务？"}}],"edges":[]}'),
  ('asst_003', 'Dify 客服助手', 'dify', 'pipeline', '', TRUE,
   NULL, '', 'https://api.dify.ai/v1', 'app-dify-demo-key', '', '{}'),
  ('asst_004', 'FastGPT 售后助手', 'fastgpt', 'pipeline', '', TRUE,
   NULL, '', 'https://api.fastgpt.in/api/v1/chat/completions', 'fastgpt-demo-key', 'app-fastgpt-001', '{}'),
  ('asst_005', 'OpenCode 代码助手', 'opencode', 'pipeline', '', TRUE,
   NULL, '你是一个代码助手的语音界面，用简洁口语回答工程问题。', 'http://localhost:4096', 'opencode-demo-key', '', '{}')
ON CONFLICT (id) DO NOTHING;

INSERT INTO assistant_model_bindings
  (assistant_id, capability, model_resource_id, config)
VALUES
  ('asst_001', 'LLM', 'model_001', '{}'),
  ('asst_001', 'ASR', 'model_002', '{}'),
  ('asst_001', 'TTS', 'model_004', '{}'),
  ('asst_002', 'ASR', 'model_002', '{}'),
  ('asst_002', 'TTS', 'model_004', '{}'),
  ('asst_003', 'ASR', 'model_002', '{}'),
  ('asst_003', 'TTS', 'model_004', '{}'),
  ('asst_004', 'ASR', 'model_002', '{}'),
  ('asst_004', 'TTS', 'model_004', '{}'),
  ('asst_005', 'ASR', 'model_002', '{}'),
  ('asst_005', 'TTS', 'model_004', '{}')
ON CONFLICT (assistant_id, capability) DO UPDATE SET
  model_resource_id = EXCLUDED.model_resource_id,
  updated_at = now();
