UNPKG

@difizen/magent-au

Version:
68 lines 8.55 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { StartNode, EndNode, KnowledgeNode, LLMNode, IfElseNode, NodesPanel, Flow } from '@difizen/magent-flow'; import { Tabs } from 'antd'; import yaml from 'js-yaml'; import { CharacterSetting } from "../../agent-config/components/character-setting/index.js"; import agentIcon from "../icons/agent.svg"; import endIcon from "../icons/end.svg"; import ifelseIcon from "../icons/ifelse.svg"; import knowledgeIcon from "../icons/knowledge.svg"; import llmIcon from "../icons/llm.svg"; import startIcon from "../icons/start.svg"; import toolIcon from "../icons/tool.svg"; import { AgentNode } from "../nodes/agent.js"; import { ToolNode } from "../nodes/tool.js"; import "./index.less"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export var nodeIconMap = { start: startIcon, end: endIcon, llm: llmIcon, knowledge: knowledgeIcon, tool: toolIcon, agent: agentIcon, ifelse: ifelseIcon }; var templateNodeYaml = "\n- id: 1\n name: \u5F00\u59CB\u8282\u70B9\n description: \u5DE5\u4F5C\u6D41\u7684\u8D77\u59CB\u8282\u70B9\uFF0C\u7528\u4E8E\u8BBE\u5B9A\u542F\u52A8\u5DE5\u4F5C\u6D41\u9700\u8981\u7684\u4FE1\u606F\n type: start\n data:\n outputs:\n - name: user_input\n type: string\n description: \u7528\u6237\u672C\u8F6E\u5BF9\u8BDD\u8F93\u5165\u5185\u5BB9\n- id: 2\n position:\n x: 200\n y: 100\n name: \u7ED3\u675F\u8282\u70B9\n description: \u5DE5\u4F5C\u6D41\u7684\u6700\u7EC8\u8282\u70B9\uFF0C\u7528\u4E8E\u8FD4\u56DE\u5DE5\u4F5C\u6D41\u8FD0\u884C\u540E\u7684\u7ED3\u679C\u4FE1\u606F\n type: end\n data:\n inputs:\n input_param:\n - name: response\n type: string\n value:\n type: reference\n prompt:\n type: string\n description: \u8F93\u51FA\u5185\u5BB9\n value:\n type: reference\n content: '{{response}}'\n outputs:\n - name: output\n type: string\n- id: 3\n name: \u5927\u6A21\u578B\u8282\u70B9\n description: \u8C03\u7528\u5927\u8BED\u8A00\u6A21\u578B,\u4F7F\u7528\u53D8\u91CF\u548C\u63D0\u793A\u8BCD\u751F\u6210\u56DE\u590D\n type: llm\n data:\n inputs:\n input_param:\n - name: input\n description:\n type: string\n value:\n type: reference\n - name: background\n description:\n type: string\n value:\n type: reference\n llm_param:\n - type: string\n name: id\n value:\n type: value\n content: qwen_llm\n - type: string\n name: model_name\n value:\n content: qwen-max\n type: value\n - type: string\n name: temperature\n value:\n content: '0.7'\n type: value\n - type: string\n name: prompt\n value:\n type: value\n content: |\n \u4F60\u662F\u4E00\u4F4D\u7CBE\u901A\u4FE1\u606F\u5206\u6790\u7684ai\u52A9\u624B\u3002\u4F60\u7684\u76EE\u6807\u662F\u4F7F\u7528\u4E2D\u6587\u7ED3\u5408\u67E5\u8BE2\u7684\u80CC\u666F\u4FE1\u606F\u53CA\u4F60\u6240\u62E5\u6709\u7684\u77E5\u8BC6\u56DE\u7B54\u7528\u6237\u63D0\u51FA\u7684\u95EE\u9898\u3002\n \u4F60\u9700\u8981\u9075\u5B88\u7684\u89C4\u5219\u662F:\n 1. \u5FC5\u987B\u4F7F\u7528\u4E2D\u6587\u7ED3\u5408\u67E5\u8BE2\u7684\u80CC\u666F\u4FE1\u606F\u7ED3\u5408\u4F60\u6240\u62E5\u6709\u7684\u77E5\u8BC6\u56DE\u7B54\u7528\u6237\u63D0\u51FA\u7684\u95EE\u9898\u3002\n 2. \u7ED3\u6784\u5316\u7B54\u6848\u751F\u6210\uFF0C\u5FC5\u8981\u65F6\u901A\u8FC7\u7A7A\u884C\u63D0\u5347\u9605\u8BFB\u4F53\u9A8C\u3002\n 3. \u4E0D\u91C7\u7528\u80CC\u666F\u4FE1\u606F\u4E2D\u7684\u9519\u8BEF\u4FE1\u606F\u3002\n 4. \u8981\u8003\u8651\u7B54\u6848\u548C\u95EE\u9898\u7684\u76F8\u5173\u6027\uFF0C\u4E0D\u505A\u5BF9\u95EE\u9898\u6CA1\u6709\u5E2E\u52A9\u7684\u56DE\u7B54\u3002\n 5. \u8BE6\u5C3D\u56DE\u7B54\u95EE\u9898\uFF0C\u91CD\u70B9\u7A81\u51FA\uFF0C\u4E0D\u8FC7\u591A\u82B1\u54E8\u8BCD\u85FB\u3002\n 6. \u4E0D\u8BF4\u6A21\u7CCA\u7684\u63A8\u6D4B\u3002\n 7. \u5C3D\u91CF\u591A\u7684\u4F7F\u7528\u6570\u503C\u7C7B\u4FE1\u606F\u3002\n\n \u80CC\u666F\u4FE1\u606F\u662F:\n {{background}}\n\n \u5F00\u59CB!\n \u9700\u8981\u56DE\u7B54\u7684\u95EE\u9898\u662F: {{input}}\n outputs:\n - type: string\n name: output\n- id: 4\n name: \u77E5\u8BC6\u5E93\n description:\n type: knowledge\n data:\n inputs:\n knowledge_param:\n - type: string\n name: id\n input_param:\n - type: string\n name: query # \u81EA\u7136\u8BED\u8A00\u7684\u77E5\u8BC6\u5E93query\n value:\n type: reference\n outputs:\n - name: output\n type: string\n- id: 5\n name: \u5DE5\u5177\n description:\n type: tool\n data:\n inputs:\n tool_param:\n - type: string\n name: id\n outputs:\n - name: output\n type: string\n- id: 6\n name: \u667A\u80FD\u4F53\n description:\n type: agent\n data:\n inputs:\n agent_param:\n - name: id\n type: string\n - name: prompt\n type: string\n value:\n type: value\n content: |\n \u9700\u8981\u56DE\u7B54\u7684\u95EE\u9898\u662F: {{input}}\n input_param:\n - type: string\n name: input\n value:\n type: reference\n\n outputs:\n - name: output\n type: string\n- id: 7\n name: \u6761\u4EF6\u5224\u65AD\n description:\n type: ifelse\n data:\n inputs:\n branches:\n - name: branch-1\n conditions:\n - compare: equal\n left:\n type: string\n value:\n type: reference\n right: # blank \u6CA1\u6709right\n type: string # \u53EA\u6709 if \u548C else\uFF0Cbranch-1\u548Cbranch-default\n value:\n type: reference\n"; export var NodeSchemaParser = function NodeSchemaParser(obj) { obj['config'] = obj['data']; var type = obj['type']; obj['icon'] = nodeIconMap[type] || 'https://mdn.alipayobjects.com/huamei_xbkogb/afts/img/A*PzmdRpvZz58AAAAAAAAAAAAADqarAQ/original'; delete obj['data']; }; var nodeTypes = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, 'start', StartNode), 'end', EndNode), 'llm', LLMNode), 'knowledge', KnowledgeNode), 'ifelse', IfElseNode), 'agent', AgentNode), 'tool', ToolNode); export var FlowWithTabs = function FlowWithTabs(props) { var toolbar = props.toolbar; var templateNodes = yaml.load(templateNodeYaml); templateNodes.forEach(function (item) { NodeSchemaParser(item); }); return /*#__PURE__*/_jsxs("div", { className: "flex flex-1", children: [/*#__PURE__*/_jsx(Tabs, { className: "agent-flow-tabs", defaultActiveKey: "node", centered: true, items: [{ key: 'node', label: '节点', children: /*#__PURE__*/_jsx(NodesPanel, { className: "w-[200px] z-10 h-full", nodes: templateNodes }) }, { key: 'settings', label: '配置', children: /*#__PURE__*/_jsx(CharacterSetting, {}) }] }), /*#__PURE__*/_jsx(Flow, { classNames: "flex-1", nodeTypes: nodeTypes, toolbar: toolbar })] }); };