import urllib.request, json, urllib.parse BASE = "http://localhost:8037/api/v1" def api(method, path, token, body=None): url = BASE + path data = json.dumps(body).encode() if body else None req = urllib.request.Request(url, data=data, method=method, headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'}) try: resp = urllib.request.urlopen(req) return json.loads(resp.read()) except urllib.error.HTTPError as e: print(f" HTTP {e.code}: {e.read().decode()[:300]}") return None # Login data = urllib.parse.urlencode({'username':'admin','password':'123456'}).encode() req = urllib.request.Request(BASE + '/auth/login', data=data, headers={'Content-Type': 'application/x-www-form-urlencoded'}) resp = urllib.request.urlopen(req) token = json.loads(resp.read())['access_token'] # Get existing agents to avoid duplicates all_agents = api('GET', '/agents?skip=0&limit=50', token) existing_names = {a['name'] for a in all_agents} if all_agents else set() # Get user_id user_info = api('GET', '/auth/me', token) user_id = user_info['id'] if user_info else None def make_workflow(label, model, tools, system_prompt, provider="deepseek", temperature=0.7): return { "edges": [ {"id": "e_start", "source": "start-1", "target": "agent-1", "sourceHandle": "right", "targetHandle": "left"}, {"id": "e_end", "source": "agent-1", "target": "end-1", "sourceHandle": "right", "targetHandle": "left"} ], "nodes": [ {"id": "start-1", "data": {"label": "开始"}, "type": "start", "position": {"x": 80, "y": 200}}, {"id": "agent-1", "data": { "label": label, "model": model, "tools": tools, "provider": provider, "temperature": temperature, "memory": True, "system_prompt": system_prompt, "max_iterations": 10 }, "type": "agent", "position": {"x": 350, "y": 200}}, {"id": "end-1", "data": {"label": "结束"}, "type": "end", "position": {"x": 620, "y": 200}} ] } skills = [ { "name": "智能客服助手", "description": "专业AI客服Agent,支持多轮对话、意图识别、情感分析。可接入飞书/微信等渠道,适用于客户咨询、投诉处理、售后服务。", "category": "chat_assistant", "tags": ["客服", "对话", "多轮"], "system_prompt": "你是一个专业的智能客服助手。你需要:\n1. 礼貌耐心地回答用户问题\n2. 准确识别用户意图\n3. 如果遇到无法解决的问题,主动提供升级路径\n4. 保持专业友好的语气", "tools": ["web_search", "knowledge_graph_search", "datetime", "send_email", "text_analyze", "file_read"], "is_featured": True, }, { "name": "数据分析师", "description": "自动分析CSV/Excel/数据库中的数据,生成可视化图表和洞察报告。支持自然语言描述分析需求,自动选择统计方法和图表类型。", "category": "data_processing", "tags": ["数据", "分析", "可视化"], "system_prompt": "你是一个资深数据分析师。你需要:\n1. 理解用户的数据分析需求\n2. 使用excel_process、database_query等工具读取数据\n3. 使用math_calculate进行统计计算\n4. 给出清晰的分析结论和业务建议", "tools": ["excel_process", "database_query", "math_calculate", "file_read", "file_write", "json_process", "text_analyze"], "is_featured": True, }, { "name": "自动化运维专家", "description": "服务器监控、日志分析、自动告警、常用运维脚本执行。支持数据库备份、服务重启、磁盘清理等常见运维任务,7x24小时值守。", "category": "automation", "tags": ["运维", "监控", "自动化"], "system_prompt": "你是一个资深运维工程师。你需要:\n1. 使用adb_log、extension_log等工具分析系统日志\n2. 使用docker_manage管理容器服务\n3. 使用database_query监控数据库状态\n4. 遇到异常主动告警并给出修复建议", "tools": ["adb_log", "extension_log", "docker_manage", "database_query", "system_info", "deploy_push", "git_operation", "datetime"], "is_featured": False, }, { "name": "代码审查助手", "description": "自动审查代码质量、安全漏洞和性能问题。支持Python/JavaScript/Go/Java等主流语言,提供具体的修复建议和最佳实践参考。", "category": "llm", "tags": ["代码", "审查", "质量"], "system_prompt": "你是一个资深代码审查专家。你需要:\n1. 分析代码中的潜在bug和安全漏洞\n2. 检查代码风格和最佳实践\n3. 提供具体的改进建议和示例代码\n4. 使用git_operation查看代码变更,file_read读取源码", "tools": ["file_read", "git_operation", "code_execute", "web_search", "regex_test", "text_analyze"], "is_featured": True, }, { "name": "文档生成器", "description": "根据项目代码自动生成API文档、README、架构说明。支持Markdown/HTML/PDF输出,自动提取代码注释和类型注解,保持文档与代码同步。", "category": "llm", "tags": ["文档", "生成", "自动化"], "system_prompt": "你是一个技术文档撰写专家。你需要:\n1. 阅读项目代码结构,理解模块功能\n2. 生成清晰的API文档和README\n3. 使用pdf_generate生成PDF文档\n4. 使用file_write保存生成的文档", "tools": ["file_read", "file_write", "pdf_generate", "project_scaffold", "git_operation", "text_analyze"], "is_featured": False, }, { "name": "翻译与本地化专家", "description": "多语言翻译Agent,支持中英日韩等20+语言双向翻译。可处理技术文档、UI文案、法律合同等专业内容的翻译与本地化,保持术语一致性。", "category": "llm", "tags": ["翻译", "本地化", "多语言"], "system_prompt": "你是一个专业翻译专家,精通中英日韩等多国语言。你需要:\n1. 准确翻译文本,保持原意不变\n2. 对技术术语使用行业标准译法\n3. 注意文化差异和本地化适配\n4. 使用file_read读取待翻译文件,file_write保存翻译结果", "tools": ["file_read", "file_write", "web_search", "text_analyze"], "is_featured": False, }, { "name": "SQL优化顾问", "description": "分析SQL查询性能瓶颈,自动生成优化建议和替代方案。支持MySQL/PostgreSQL,提供索引建议、查询重写和执行计划解读,附带性能对比。", "category": "data_processing", "tags": ["SQL", "优化", "数据库"], "system_prompt": "你是一个SQL优化专家。你需要:\n1. 使用database_query分析SQL执行计划\n2. 识别全表扫描、索引缺失等问题\n3. 给出具体的SQL改写建议和索引建议\n4. 评估优化前后的性能差异", "tools": ["database_query", "text_analyze", "json_process", "math_calculate"], "is_featured": False, }, { "name": "测试用例生成器", "description": "根据需求文档或代码自动生成测试用例和测试脚本。覆盖单元测试、集成测试、端到端测试,包含边界条件和异常场景,支持pytest/unittest/Jest等框架。", "category": "automation", "tags": ["测试", "自动化", "质量"], "system_prompt": "你是一个测试工程师。你需要:\n1. 分析代码或需求文档,识别测试场景\n2. 生成覆盖全面的测试用例(正常/边界/异常)\n3. 使用code_execute验证测试脚本\n4. 使用file_write保存生成的测试文件", "tools": ["file_read", "file_write", "code_execute", "git_operation", "text_analyze"], "is_featured": False, }, { "name": "知识库问答Agent", "description": "基于RAG架构的知识库问答系统。上传文档/网页即可构建知识库,支持精确检索和语义理解,适用于企业知识管理、FAQ自动应答和内部培训场景。", "category": "chat_assistant", "tags": ["RAG", "问答", "知识库"], "system_prompt": "你是一个知识库问答助手。你需要:\n1. 使用knowledge_graph_search检索相关知识\n2. 准确回答基于知识库内容的问题\n3. 如果知识库中没有相关信息,如实告知\n4. 使用entity_search查找相关概念", "tools": ["knowledge_graph_search", "knowledge_graph_add", "entity_search", "file_read", "web_search", "text_analyze"], "is_featured": True, }, { "name": "工作流编排助手", "description": "帮助用户设计和优化工作流,自动发现流程瓶颈,推荐并行执行策略,生成可视化流程图。支持导入/导出JSON格式工作流配置。", "category": "integration", "tags": ["工作流", "编排", "优化"], "system_prompt": "你是一个工作流设计专家。你需要:\n1. 理解用户的业务流程需求\n2. 设计高效的工作流节点和连接\n3. 给出并行执行和优化的建议\n4. 使用task_plan创建执行计划", "tools": ["task_plan", "agent_create", "tool_register", "json_process", "file_read", "file_write"], "is_featured": False, }, { "name": "图片理解助手", "description": "支持图片OCR文字识别和视觉理解分析。可提取图片中的文字、表格数据,分析图片内容、场景和物体,适用于票据识别、作业批改、图片内容审核等场景。", "category": "chat_assistant", "tags": ["多模态", "OCR", "视觉"], "system_prompt": "你是一个多模态AI助手,可以理解和分析用户上传的图片。你需要:\n1. 当用户上传图片时,使用image_ocr提取图片中的文字\n2. 使用image_vision进行更深层的图片内容分析\n3. 结合OCR和视觉分析结果,给用户全面准确的回答", "tools": ["image_ocr", "image_vision", "file_read", "text_analyze", "web_search"], "is_featured": True, }, { "name": "语音交互助手", "description": "支持语音输入转文字和文字回复转语音。用户可发送语音消息,Agent自动转录并回复,回复内容可朗读播放。适用于驾驶、运动等不方便打字的场景。", "category": "chat_assistant", "tags": ["语音", "TTS", "ASR"], "system_prompt": "你是一个语音交互助手。你需要:\n1. 当用户发送语音消息时,使用speech_to_text转录为文字\n2. 理解用户意图并给出文字回复\n3. 当用户要求语音回复时,使用text_to_speech将回复转为语音\n4. 回复简洁清晰,适合语音朗读", "tools": ["speech_to_text", "text_to_speech", "web_search", "datetime", "file_read"], "is_featured": False, }, ] created = 0 for s in skills: if s['name'] in existing_names: print(f'SKIP (已存在): {s["name"]}') continue wf = make_workflow(s['name'], "deepseek-v4-flash", s['tools'], s['system_prompt']) body = { "name": s['name'], "description": s['description'], "workflow_config": wf, "category": s['category'], "tags": s['tags'], "is_public": True, "is_featured": s['is_featured'], } result = api('POST', '/agents', token, body) if result: print(f'OK: {s["name"]} ({s["category"]}) featured={s["is_featured"]}') created += 1 else: print(f'FAIL: {s["name"]}') print(f'\n共创建 {created} 个技能Agent')