在构建智能对话应用时,准确识别用户意图是关键一步。但实际上看似简单,大家却总是遇到输出不可控,难以提升准确率,响应速度慢等难题。下面直接看我如何开发一个全局意图识别插件(本插件基于FastGPT),旨在提供一个通用且高效的全局意图识别方案,让您的应用能够快速理解用户在不同场景下的需求。当然不是FastGPT用户也可以参考学习。
核心优势
高度通用: 可配置 5-10 种任意场景意图(如:查酒店、问天气、订机票等),插件本身与具体行业无关。
配置简便: 通过简单的一个 JSON 配置,即可定义您的场景意图。
快速集成: 作为 FastGPT 插件,易于集成到现有工作流中。
精准度高!(完全自主可控的场景名称和场景描述)
输出速度快!(仅让LLM输出 1个Token)
插件原理
本插件通过预设场景意图和一段 JavaScript 代码,将用户的意图识别转化为一个选择过程。用户输入问题后,插件会列出可能的场景选项,用户回复序号即可初步判断其意图。
快速上手:进FastGPT的应用/工作台-新建「插件」,直接JSON 导入。
直接上干货。
{
"nodes": [
{
"nodeId": "r420rE3NMicW",
"name": "场景配置模板",
"intro": "可以更新指定节点的输出值或更新全局变量",
"avatar": "core/workflow/template/variableUpdate",
"flowNodeType": "variableUpdate",
"showStatus": false,
"position": {
"x": 643.430584499503,
"y": -2676.9110753427344
},
"version": "481",
"inputs": [
{
"key": "updateList",
"valueType": "any",
"label": "",
"renderTypeList": [
"hidden"
],
"value": [
{
"variable": [
"yG2j1gWQLcx2",
"场景配置"
],
"value": [
"",
"{\n\"scene\":[\n\t{\n\t\t\"index\":1,\n\t\t\"scene_name\":\"打招呼\",\n\t\t\"description\":\"打招呼,问身份\"\n\t},\n\t{\n\t\t\"index\":2,\n\t\t\"scene_name\":\"查天气\",\n\t\t\"description\":\"天气查询\"\n\t},\n\t{\n\t\t\"index\":0,\n\t\t\"scene_name\":\"其他场景\",\n\t\t\"description\":\"其他未识别的场景\"\n\t}\n]\n}"
],
"valueType": "any",
"renderType": "input"
}
]
}
],
"outputs": []
},
{
"nodeId": "wSTMAw0NymtX",
"name": "prompt 场景识别",
"intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。",
"avatar": "core/workflow/template/codeRun",
"flowNodeType": "code",
"showStatus": true,
"position": {
"x": 2471.5350671574192,
"y": -867.937679127715
},
"version": "482",
"inputs": [
{
"key": "system_addInputParam",
"renderTypeList": [
"addInputParam"
],
"valueType": "dynamic",
"label": "",
"required": false,
"description": "workflow:these_variables_will_be_input_parameters_for_code_execution",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
}
},
{
"key": "codeType",
"renderTypeList": [
"hidden"
],
"label": "",
"value": "js"
},
{
"key": "code",
"renderTypeList": [
"custom"
],
"label": "",
"value": "function processSceneData(jsonString, question, message_history) {\n let data;\n try {\n data = JSON.parse(jsonString); // 解析 JSON 字符串\n } catch (error) {\n return \"Invalid JSON string provided.\";\n }\n\n const scenes = data.scene;\n\n if (!Array.isArray(scenes)) {\n return \"Scene data is missing or not in the correct format.\";\n }\n\n let output = \"有下面多种场景,需要你根据用户输入进行判断,只答选项\\n\";\n\n scenes.forEach(scene => {\n output += `${scene.index}. ${scene.scene_name} (${scene.description}) - 请回复${scene.index}\\n`;\n });\n\n output += `\\n历史对话:\\n${message_history}\\n\\n当前用户输入:${question}\\n\\n请回复序号:`;\n\n return output;\n}\n\nfunction main({ scene_templates, question, message_history }) {\n const processedResult = processSceneData(scene_templates, question, message_history);\n\n return {\n result: processedResult\n };\n}\n"
},
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "scene_templates",
"label": "scene_templates",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"yG2j1gWQLcx2",
"场景配置"
]
},
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "question",
"label": "question",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"yG2j1gWQLcx2",
"用户问题"
]
},
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "message_history",
"label": "message_history",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"VARIABLE_NODE_ID",
"message_history"
]
}
],
"outputs": [
{
"id": "system_rawResponse",
"key": "system_rawResponse",
"label": "workflow:full_response_data",
"valueType": "object",
"type": "static"
},
{
"id": "error",
"key": "error",
"label": "workflow:execution_error",
"description": "workflow:error_info_returns_empty_on_success",
"valueType": "object",
"type": "static"
},
{
"id": "system_addOutputParam",
"key": "system_addOutputParam",
"type": "dynamic",
"valueType": "dynamic",
"label": "",
"customFieldConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": false
},
"description": "workflow:pass_returned_object_as_output_to_next_nodes"
},
{
"id": "dQAAhTlN8BR7",
"valueType": "string",
"type": "dynamic",
"key": "result",
"label": "result"
}
]
},
{
"nodeId": "kCOHs1qWi26e",
"name": "解析场景识别",
"intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。",
"avatar": "core/workflow/template/codeRun",
"flowNodeType": "code",
"showStatus": true,
"position": {
"x": 3363.7984380061507,
"y": -867.937679127715
},
"version": "482",
"inputs": [
{
"key": "system_addInputParam",
"renderTypeList": [
"addInputParam"
],
"valueType": "dynamic",
"label": "",
"required": false,
"description": "workflow:these_variables_will_be_input_parameters_for_code_execution",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
}
},
{
"key": "codeType",
"renderTypeList": [
"hidden"
],
"label": "",
"value": "js"
},
{
"key": "code",
"renderTypeList": [
"custom"
],
"label": "",
"value": "function extractFirstNumber(str) {\n const match = str.match(/\\d+/);\n return match ? match[0] : null;\n}\n\nfunction getSceneNameByIndex(jsonString, index) {\n let data;\n try {\n data = JSON.parse(jsonString); // 解析 JSON 字符串\n } catch (error) {\n return \"Invalid JSON string provided.\";\n }\n\n const scenes = data.scene;\n\n if (!Array.isArray(scenes)) {\n return \"Scene data is missing or not in the correct format.\";\n }\n\n const scene = scenes.find(scene => scene.index == index);\n\n if (!scene) {\n return `No scene found with index ${index}`;\n }\n\n return scene.scene_name;\n}\n\nfunction main({ scene_templates, number_string }) {\n const index = extractFirstNumber(number_string);\n const sceneNameResult = getSceneNameByIndex(scene_templates, index);\n\n return {\n result: sceneNameResult\n };\n}"
},
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "number_string",
"label": "number_string",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"rSHlPFFZLzlB",
"answerText"
]
},
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "scene_templates",
"label": "scene_templates",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"yG2j1gWQLcx2",
"场景配置"
]
}
],
"outputs": [
{
"id": "system_rawResponse",
"key": "system_rawResponse",
"label": "workflow:full_response_data",
"valueType": "object",
"type": "static"
},
{
"id": "error",
"key": "error",
"label": "workflow:execution_error",
"description": "workflow:error_info_returns_empty_on_success",
"valueType": "object",
"type": "static"
},
{
"id": "system_addOutputParam",
"key": "system_addOutputParam",
"type": "dynamic",
"valueType": "dynamic",
"label": "",
"customFieldConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": false
},
"description": "workflow:pass_returned_object_as_output_to_next_nodes"
},
{
"id": "qLUQfhG0ILRX",
"type": "dynamic",
"key": "result",
"valueType": "string",
"label": "result"
}
]
},
{
"nodeId": "aNFKb3okCvlV",
"name": "更新识别场景",
"intro": "可以更新指定节点的输出值或更新全局变量",
"avatar": "core/workflow/template/variableUpdate",
"flowNodeType": "variableUpdate",
"showStatus": false,
"position": {
"x": 3845.662726639011,
"y": -867.937679127715
},
"version": "481",
"inputs": [
{
"key": "updateList",
"valueType": "any",
"label": "",
"renderTypeList": [
"hidden"
],
"value": [
{
"variable": [
"VARIABLE_NODE_ID",
"last_scene"
],
"value": [
"kCOHs1qWi26e",
"qLUQfhG0ILRX"
],
"valueType": "any",
"renderType": "reference"
}
]
}
],
"outputs": []
},
{
"nodeId": "popAdjQFSjrc",
"name": "对话记录",
"intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。",
"avatar": "core/workflow/template/codeRun",
"flowNodeType": "code",
"showStatus": true,
"position": {
"x": 4302.689187930924,
"y": -3540.2822929476674
},
"version": "482",
"inputs": [
{
"key": "system_addInputParam",
"renderTypeList": [
"addInputParam"
],
"valueType": "dynamic",
"label": "",
"required": false,
"description": "workflow:these_variables_will_be_input_parameters_for_code_execution",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
}
},
{
"key": "codeType",
"renderTypeList": [
"hidden"
],
"label": "",
"value": "js"
},
{
"key": "code",
"renderTypeList": [
"custom"
],
"label": "",
"value": "function extractContent(data, limit) {\n // 如果 limit 是字符串,将其转换为整数\n if (typeof limit === 'string') {\n limit = parseInt(limit, 10);\n }\n\n // 检查 limit 是否为有效数字且大于0\n if (isNaN(limit) || limit <= 0) {\n return []; // 如果 limit 无效,返回空数组\n }\n\n // 提取内容\n const result = data.map(item => {\n return {\n role: item.obj,\n content: item.value[0].text.content\n };\n });\n\n // 使用 slice 根据 limit 返回最后几个元素\n return result.slice(-limit);\n}\n\nfunction formatOutput(data) {\n // 格式化输出为 \"角色:内容\" 的形式,并过滤掉内容开头的换行符\n return data.map(item => {\n // 使用 trim() 方法去掉内容开头的换行符\n const content = item.content.startsWith('\\n') ? item.content.slice(1) : item.content;\n\n // 截断内容,如果长度超过 50 则添加 ...\n const truncatedContent = content.length > 50 ? content.slice(0, 50) + '...' : content;\n\n return `${item.role}:${truncatedContent.trim()}`; // 也去掉内容末尾的空格\n }).join('\\n');\n}\n\nfunction main({data, limit}) {\n const extractedContent = extractContent(data, limit);\n return {\n result: formatOutput(extractedContent) // 调用格式化函数\n };\n}"
},
{
"renderTypeList": [
"reference"
],
"valueType": "number",
"canEdit": true,
"key": "limit",
"label": "limit",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"yG2j1gWQLcx2",
"记忆长度"
]
},
{
"renderTypeList": [
"reference"
],
"valueType": "chatHistory",
"canEdit": true,
"key": "data",
"label": "data",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": [
"VARIABLE_NODE_ID",
"histories"
]
}
],
"outputs": [
{
"id": "system_rawResponse",
"key": "system_rawResponse",
"label": "workflow:full_response_data",
"valueType": "object",
"type": "static"
},
{
"id": "error",
"key": "error",
"label": "workflow:execution_error",
"description": "workflow:error_info_returns_empty_on_success",
"valueType": "object",
"type": "static"
},
{
"id": "system_addOutputParam",
"key": "system_addOutputParam",
"type": "dynamic",
"valueType": "dynamic",
"label": "",
"customFieldConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": false
},
"description": "workflow:pass_returned_object_as_output_to_next_nodes"
},
{
"id": "qLUQfhG0ILRX",
"type": "dynamic",
"key": "result",
"valueType": "string",
"label": "result"
}
]
},
{
"nodeId": "e2NyU8kIyZ0Z",
"name": "记忆长度-默认4(即前2两轮)",
"intro": "可以更新指定节点的输出值或更新全局变量",
"avatar": "core/workflow/template/variableUpdate",
"flowNodeType": "variableUpdate",
"showStatus": false,
"position": {
"x": 643.430584499503,
"y": -3098.141839086796
},
"version": "481",
"inputs": [
{
"key": "updateList",
"valueType": "any",
"label": "",
"renderTypeList": [
"hidden"
],
"value": [
{
"variable": [
"yG2j1gWQLcx2",
"记忆长度"
],
"value": [
"",
"4"
],
"valueType": "any",
"renderType": "input"
}
]
}
],
"outputs": []
},
{
"nodeId": "rSHlPFFZLzlB",
"name": "AI 场景识别",
"intro": "AI 大模型对话",
"avatar": "core/workflow/template/aiChat",
"flowNodeType": "chatNode",
"showStatus": true,
"position": {
"x": 2935.5584550357826,
"y": -867.937679127715
},
"version": "481",
"inputs": [
{
"key": "model",
"renderTypeList": [
"settingLLMModel",
"reference"
],
"label": "common:core.module.input.label.aiModel",
"valueType": "string",
"selectedTypeIndex": 1,
"value": [
"yG2j1gWQLcx2",
"模型id"
]
},
{
"key": "temperature",
"renderTypeList": [
"hidden"
],
"label": "",
"value": 0,
"valueType": "number"
},
{
"key": "maxToken",
"renderTypeList": [
"hidden"
],
"label": "",
"value": 2000,
"valueType": "number"
},
{
"key": "isResponseAnswerText",
"renderTypeList": [
"hidden"
],
"label": "",
"value": false,
"valueType": "boolean"
},
{
"key": "quoteTemplate",
"renderTypeList": [
"hidden"
],
"label": "",
"valueType": "string"
},
{
"key": "quotePrompt",
"renderTypeList": [
"hidden"
],
"label": "",
"valueType": "string"
},
{
"key": "aiChatVision",
"renderTypeList": [
"hidden"
],
"label": "",
"valueType": "boolean",
"value": false
},
{
"key": "systemPrompt",
"renderTypeList": [
"textarea",
"reference"
],
"max": 3000,
"valueType": "string",
"label": "common:core.ai.Prompt",
"description": "core.app.tip.chatNodeSystemPromptTip",
"placeholder": "core.app.tip.chatNodeSystemPromptTip"
},
{
"key": "history",
"renderTypeList": [
"numberInput",
"reference"
],
"valueType": "chatHistory",
"label": "common:core.module.input.label.chat history",
"description": "workflow:max_dialog_rounds",
"required": true,
"min": 0,
"max": 50,
"value": 0
},
{
"key": "quoteQA",
"renderTypeList": [
"settingDatasetQuotePrompt"
],
"label": "",
"debugLabel": "workflow:knowledge_base_reference",
"description": "",
"valueType": "datasetQuote"
},
{
"key": "stringQuoteText",
"renderTypeList": [
"reference",
"textarea"
],
"label": "app:document_quote",
"debugLabel": "app:document_quote",
"description": "app:document_quote_tip",
"valueType": "string"
},
{
"key": "userChatInput",
"renderTypeList": [
"reference",
"textarea"
],
"valueType": "string",
"label": "workflow:user_question",
"required": true,
"toolDescription": "workflow:user_question",
"value": [
"wSTMAw0NymtX",
"dQAAhTlN8BR7"
]
}
],
"outputs": [
{
"id": "history",
"key": "history",
"required": true,
"label": "common:core.module.output.label.New context",
"description": "common:core.module.output.description.New context",
"valueType": "chatHistory",
"valueDesc": "{\n obj: System | Human | AI;\n value: string;\n}[]",
"type": "static"
},
{
"id": "answerText",
"key": "answerText",
"required": true,
"label": "common:core.module.output.label.Ai response content",
"description": "common:core.module.output.description.Ai response content",
"valueType": "string",
"type": "static"
}
]
},
{
"nodeId": "hjsfUb9ihz5z",
"name": "更新变量-简版对话记录",
"intro": "可以更新指定节点的输出值或更新全局变量",
"avatar": "core/workflow/template/variableUpdate",
"flowNodeType": "variableUpdate",
"showStatus": false,
"position": {
"x": 4321.689187930924,
"y": -2596.708591672205
},
"version": "481",
"inputs": [
{
"key": "updateList",
"valueType": "any",
"label": "",
"renderTypeList": [
"hidden"
],
"value": [
{
"variable": [
"VARIABLE_NODE_ID",
"message_history"
],
"value": [
"popAdjQFSjrc",
"qLUQfhG0ILRX"
],
"valueType": "any",
"renderType": "reference"
}
]
}
],
"outputs": []
},
{
"nodeId": "mTLWvYQ3F1GN",
"name": "API模板(兼容GPTs schema)",
"intro": "可以更新指定节点的输出值或更新全局变量",
"avatar": "core/workflow/template/variableUpdate",
"flowNodeType": "variableUpdate",
"showStatus": false,
"position": {
"x": 643.430584499503,
"y": -3540.567414127787
},
"version": "481",
"inputs": [
{
"key": "updateList",
"valueType": "any",
"label": "",
"renderTypeList": [
"hidden"
],
"value": [
{
"variable": [
"yG2j1gWQLcx2",
"API配置"
],
"value": [
"",
"{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"新闻API\",\n \"description\": \"获取最新新闻列表\",\n \"version\": \"v1.0.0\"\n },\n \"servers\": [\n {\n \"url\": \"https://v.juhe.cn\"\n }\n ],\n \"paths\": {\n \"/toutiao/index\": {\n \"get\": {\n \"summary\": \"Get news from Juhe API\",\n \"operationId\": \"getNews\",\n \"parameters\": [\n {\n \"name\": \"type\",\n \"in\": \"query\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n },\n \"default\": \"guonei\"\n },\n {\n \"name\": \"page\",\n \"in\": \"query\",\n \"required\": true,\n \"schema\": {\n \"type\": \"integer\"\n },\n \"default\": 1\n },\n {\n \"name\": \"page_size\",\n \"in\": \"query\",\n \"required\": true,\n \"schema\": {\n \"type\": \"integer\"\n },\n \"default\": 30\n },\n {\n \"name\": \"is_filter\",\n \"in\": \"query\",\n \"required\": true,\n \"schema\": {\n \"type\": \"integer\"\n },\n \"default\": 0\n },\n {\n \"name\": \"key\",\n \"in\": \"query\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n },\n \"default\": \"cb53bd41a74ef445a2d1b7fcfebe6fa0\"\n }\n ]\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"NewsItem\": {\n \"type\": \"object\",\n \"properties\": {\n \"uniquekey\": {\n \"type\": \"string\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"category\": {\n \"type\": \"string\"\n },\n \"author_name\": {\n \"type\": \"string\"\n },\n \"url\": {\n \"type\": \"string\",\n \"format\": \"uri\"\n },\n \"thumbnail_pic_s\": {\n \"type\": \"string\"\n },\n \"is_content\": {\n \"type\": \"string\",\n \"enum\": [\n \"0\",\n \"1\"\n ]\n }\n },\n \"required\": [\n \"uniquekey\",\n \"title\",\n \"date\",\n \"category\",\n \"author_name\",\n \"url\",\n \"is_content\"\n ]\n },\n \"ApiResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"reason\": {\n \"type\": \"string\"\n },\n \"result\": {\n \"type\": \"object\",\n \"properties\": {\n \"stat\": {\n \"type\": \"string\"\n },\n \"data\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/NewsItem\"\n }\n }\n },\n \"required\": [\n \"stat\",\n \"data\"\n ]\n }\n },\n \"required\": [\n \"reason\",\n \"result\"\n ]\n }\n }\n }\n}"
],
"valueType": "any",
"renderType": "input"
}
]
}
],
"outputs": []
},
{
"nodeId": "jex7KfJUcRWz",
"name": "场景配置初始化",
"intro": "根据一定的条件,执行不同的分支。",
"avatar": "core/workflow/template/ifelse",
"flowNodeType": "ifElseNode",
"showStatus": true,
"position": {
"x": -134.1757347103037,
"y": -2676.9110753427344
},
"version": "481",
"inputs": [
{
"key": "ifElseList",
"renderTypeList": [
"hidden"
],
"valueType": "any",
"label": "",
"value": [
{
"condition": "AND",
"list": [
{
"variable": [
"yG2j1gWQLcx2",
"场景配置"
],
"condition": "isEmpty"
}
]
}
]
}
],
"outputs": [
{
"id": "ifElseResult",
"key": "ifElseResult",
"label": "workflow:judgment_result",
"valueType": "string",
"type": "static"
}
]
},
{
"nodeId": "fkawJCv2Ruvn",
"name": "开始初始化流程",
"intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
"avatar": "core/workflow/template/textConcat",
"flowNodeType": "textEditor",
"position": {
"x": -934.818729001512,
"y": -1719.988177545715
},
"version": "486",
"inputs": [
{
"key": "system_addInputParam",
"renderTypeList": [
"addInputParam"
],
"valueType": "dynamic",
"label": "",
"required": false,
"description": "workflow:dynamic_input_description_concat",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": false
}
},
{
"key": "system_textareaInput",
"renderTypeList": [
"textarea"
],
"valueType": "string",
"required": true,
"label": "workflow:concatenation_text",
"placeholder": "workflow:input_variable_list",
"value": "# 开始初始化流程"
}
],
"outputs": [
{
"id": "system_text",
"key": "system_text",
"label": "workflow:concatenation_result",
"type": "static",
"valueType": "string"
}
]
},
{
"nodeId": "foMRx5X2uBeJ",
"name": "API配置初始化",
"intro": "根据一定的条件,执行不同的分支。",
"avatar": "core/workflow/template/ifelse",
"flowNodeType": "ifElseNode",
"showStatus": true,
"position": {
"x": -134.1757347103037,
"y": -3540.567414127787
},
"version": "481",
"inputs": [
{
"key": "ifElseList",
"renderTypeList": [
"hidden"
],
"valueType": "any",
"label": "",
"value": [
{
"condition": "AND",
"list": [
{
"variable": [
"yG2j1gWQLcx2",
"API配置"
],
"condition": "isEmpty"
}
]
}
]
}
],
"outputs": [
{
"id": "ifElseResult",
"key": "ifElseResult",
"label": "workflow:judgment_result",
"valueType": "string",
"type": "static"
}
]
},
{
"nodeId": "jJyM91jK1n8X",
"name": "记忆长度初始化",
"intro": "根据一定的条件,执行不同的分支。",
"avatar": "core/workflow/template/ifelse",
"flowNodeType": "ifElseNode",
"showStatus": true,
"position": {
"x": -134.1757347103037,
"y": -3098.141839086796
},
"version": "481",
"inputs": [
{
"key": "ifElseList",
"renderTypeList": [
"hidden"
],
"valueType": "any",
"label": "",
"value": [
{
"condition": "AND",
"list": [
{
"variable": [
"yG2j1gWQLcx2",
"记忆长度"
],
"condition": "isEmpty"
}
]
}
]
}
],
"outputs": [
{
"id": "ifElseResult",
"key": "ifElseResult",
"label": "workflow:judgment_result",
"valueType": "string",
"type": "static"
}
]
},
{
"nodeId": "yG2j1gWQLcx2",
"name": "插件输入",
"intro": "可以配置插件需要哪些输入,利用这些输入来运行插件",
"avatar": "core/workflow/template/workflowStart",
"flowNodeType": "pluginInput",
"showStatus": false,
"position": {
"x": -1748.7618139948142,
"y": -1708.488177545715
},
"version": "481",
"inputs": [
{
"renderTypeList": [
"JSONEditor"
],
"selectedTypeIndex": 0,
"valueType": "string",
"canEdit": true,
"key": "场景配置",
"label": "场景配置",
"description": "",
"required": false,
"defaultValue": ""
},
{
"renderTypeList": [
"numberInput"
],
"selectedTypeIndex": 0,
"valueType": "number",
"canEdit": true,
"key": "记忆长度",
"label": "记忆长度",
"description": "意图识别时参考最近的对话记录",
"required": false,
"defaultValue": "4"
},
{
"renderTypeList": [
"JSONEditor"
],
"selectedTypeIndex": 0,
"valueType": "string",
"canEdit": true,
"key": "API配置",
"label": "API配置",
"description": "",
"required": false,
"defaultValue": ""
},
{
"renderTypeList": [
"selectLLMModel"
],
"selectedTypeIndex": 0,
"valueType": "string",
"canEdit": true,
"key": "模型id",
"label": "模型id",
"description": "",
"required": false
},
{
"renderTypeList": [
"reference"
],
"selectedTypeIndex": 0,
"valueType": "string",
"canEdit": true,
"key": "用户问题",
"label": "用户问题",
"description": "",
"required": true
}
],
"outputs": [
{
"id": "场景配置",
"valueType": "string",
"key": "场景配置",
"label": "场景配置",
"type": "hidden"
},
{
"id": "记忆长度",
"valueType": "number",
"key": "记忆长度",
"label": "记忆长度",
"type": "hidden"
},
{
"id": "API配置",
"valueType": "string",
"key": "API配置",
"label": "API配置",
"type": "hidden"
},
{
"id": "模型id",
"valueType": "string",
"key": "模型id",
"label": "模型id",
"type": "hidden"
},
{
"id": "用户问题",
"valueType": "string",
"key": "用户问题",
"label": "用户问题",
"type": "hidden"
}
]
},
{
"nodeId": "xNvk0HoVoF3H",
"name": "自定义插件输出",
"intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出",
"avatar": "core/workflow/template/pluginOutput",
"flowNodeType": "pluginOutput",
"showStatus": false,
"position": {
"x": 4600.198690400537,
"y": -847.937679127715
},
"version": "481",
"inputs": [
{
"renderTypeList": [
"reference"
],
"valueType": "string",
"canEdit": true,
"key": "当前场景",
"label": "当前场景",
"description": "",
"value": [
"VARIABLE_NODE_ID",
"last_scene"
]
}
],
"outputs": []
}
],
"edges": [
{
"source": "kCOHs1qWi26e",
"target": "aNFKb3okCvlV",
"sourceHandle": "kCOHs1qWi26e-source-right",
"targetHandle": "aNFKb3okCvlV-target-left"
},
{
"source": "wSTMAw0NymtX",
"target": "rSHlPFFZLzlB",
"sourceHandle": "wSTMAw0NymtX-source-right",
"targetHandle": "rSHlPFFZLzlB-target-left"
},
{
"source": "rSHlPFFZLzlB",
"target": "kCOHs1qWi26e",
"sourceHandle": "rSHlPFFZLzlB-source-right",
"targetHandle": "kCOHs1qWi26e-target-left"
},
{
"source": "hjsfUb9ihz5z",
"target": "wSTMAw0NymtX",
"sourceHandle": "hjsfUb9ihz5z-source-right",
"targetHandle": "wSTMAw0NymtX-target-left"
},
{
"source": "popAdjQFSjrc",
"target": "hjsfUb9ihz5z",
"sourceHandle": "popAdjQFSjrc-source-bottom",
"targetHandle": "hjsfUb9ihz5z-target-top"
},
{
"source": "jex7KfJUcRWz",
"target": "r420rE3NMicW",
"sourceHandle": "jex7KfJUcRWz-source-IF",
"targetHandle": "r420rE3NMicW-target-left"
},
{
"source": "fkawJCv2Ruvn",
"target": "foMRx5X2uBeJ",
"sourceHandle": "fkawJCv2Ruvn-source-top",
"targetHandle": "foMRx5X2uBeJ-target-left"
},
{
"source": "fkawJCv2Ruvn",
"target": "jJyM91jK1n8X",
"sourceHandle": "fkawJCv2Ruvn-source-top",
"targetHandle": "jJyM91jK1n8X-target-left"
},
{
"source": "fkawJCv2Ruvn",
"target": "jex7KfJUcRWz",
"sourceHandle": "fkawJCv2Ruvn-source-top",
"targetHandle": "jex7KfJUcRWz-target-left"
},
{
"source": "foMRx5X2uBeJ",
"target": "mTLWvYQ3F1GN",
"sourceHandle": "foMRx5X2uBeJ-source-IF",
"targetHandle": "mTLWvYQ3F1GN-target-left"
},
{
"source": "jJyM91jK1n8X",
"target": "e2NyU8kIyZ0Z",
"sourceHandle": "jJyM91jK1n8X-source-IF",
"targetHandle": "e2NyU8kIyZ0Z-target-left"
},
{
"source": "fkawJCv2Ruvn",
"target": "popAdjQFSjrc",
"sourceHandle": "fkawJCv2Ruvn-source-right",
"targetHandle": "popAdjQFSjrc-target-left"
},
{
"source": "aNFKb3okCvlV",
"target": "xNvk0HoVoF3H",
"sourceHandle": "aNFKb3okCvlV-source-right",
"targetHandle": "xNvk0HoVoF3H-target-left"
},
{
"source": "yG2j1gWQLcx2",
"target": "fkawJCv2Ruvn",
"sourceHandle": "yG2j1gWQLcx2-source-right",
"targetHandle": "fkawJCv2Ruvn-target-left"
}
],
"chatConfig": {
"welcomeText": "[你好]\n[今天天气]\n[我要充值]",
"variables": [
{
"id": "zgj749",
"key": "scene_templates",
"label": "场景配置",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any"
},
{
"id": "wd0vfr",
"key": "last_scene",
"label": "当前场景",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any",
"icon": "core/app/variable/external"
},
{
"id": "tbdsyj",
"key": "context_length",
"label": "记忆长度",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any"
},
{
"id": "h5edrt",
"key": "message_history",
"label": "简版对话记录",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any"
},
{
"id": "mpqua7",
"key": "api_schema",
"label": "API配置",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any"
},
{
"id": "fjl3dy",
"key": "model_id",
"label": "模型id",
"type": "custom",
"required": false,
"maxLen": 50,
"enums": [
{
"value": ""
}
],
"valueType": "any"
}
],
"scheduledTriggerConfig": {
"cronString": "",
"timezone": "Asia/Shanghai",
"defaultPrompt": ""
},
"_id": "66d6fc05cf9e4642e2b57839"
}
}
选择模型和用户输入,然后需要用插件的时候填写场景描述JSON。
示例:
{
"scene":[
{
"index":1,
"scene_name":"打招呼",
"description":"打招呼,问身份"
},
{
"index":2,
"scene_name":"查天气",
"description":"天气查询"
},
{
"index":0,
"scene_name":"其他场景",
"description":"其他未识别的场景"
}
]
}
index从1开始就可以了,scene_name填场景名称,description填场景描述。
一键导入,快速提升您的对话应用的智能化水平。欢迎体验!