labring / FastGPT

FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, and visual AI workflow orchestration, letting you easily develop and deploy complex question-answering systems without the need for extensive setup or configuration.
https://tryfastgpt.ai
Other
17.33k stars 4.66k forks source link

通过全局变量和变量更新,将提问的方式收集起来 #2394

Closed anomone closed 1 month ago

anomone commented 2 months ago

例行检查

功能描述 能否让全局变量以提问的方式跟用户互动,最终收集数据组装成提问 再发送给ai回答 应用场景 客服 相关示例 以旅游智能客服举例 智能客服会收集三个信息,“请问您的旅游天数?”,“请问您的旅游人数?”,“请问您的旅游目的地是哪里?” 如果用全局变量去收集太生硬了。

效果用百度智能客服举例,感觉稍微改改就能实现智能客服这个方向了(或者有办法但是我能力有限没想到) image image

lijiajun1997 commented 1 month ago

从客户体验来说还不如用全局变量收集或者一次性问完呢,其实直接放在prompt提问里也可以。 按你的要求也不是不行,就是比较复杂而且浪费时间: image

lijiajun1997 commented 1 month ago

{ "nodes": [ { "nodeId": "userGuide", "name": "系统配置", "intro": "可以配置应用的系统参数", "avatar": "core/workflow/template/systemConfig", "flowNodeType": "userGuide", "position": { "x": 531.2422736065552, "y": -486.7611729549753 }, "version": "481", "inputs": [ { "key": "welcomeText", "renderTypeList": [ "hidden" ], "valueType": "string", "label": "core.app.Welcome Text", "value": "" }, { "key": "variables", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "core.app.Chat Variable", "value": [] }, { "key": "questionGuide", "valueType": "boolean", "renderTypeList": [ "hidden" ], "label": "core.app.Question Guide", "value": false }, { "key": "tts", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "", "value": { "type": "web" } }, { "key": "whisper", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "", "value": { "open": false, "autoSend": false, "autoTTSResponse": false } }, { "key": "scheduleTrigger", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "", "value": null } ], "outputs": [] }, { "nodeId": "448745", "name": "流程开始", "intro": "", "avatar": "core/workflow/template/workflowStart", "flowNodeType": "workflowStart", "position": { "x": 683.6217608535718, "y": 302.3230081757545 }, "version": "481", "inputs": [ { "key": "userChatInput", "renderTypeList": [ "reference", "textarea" ], "valueType": "string", "label": "用户问题", "required": true, "toolDescription": "用户问题" } ], "outputs": [ { "id": "userChatInput", "key": "userChatInput", "label": "common:core.module.input.label.user question", "type": "static", "valueType": "string" } ] }, { "nodeId": "y3B4gjlLbTz7", "name": "变量更新", "intro": "可以更新指定节点的输出值或更新全局变量", "avatar": "core/workflow/template/variableUpdate", "flowNodeType": "variableUpdate", "showStatus": false, "position": { "x": 2681.5762224917707, "y": -302.4419527946851 }, "version": "481", "inputs": [ { "key": "updateList", "valueType": "any", "label": "", "renderTypeList": [ "hidden" ], "value": [ { "variable": [ "VARIABLE_NODE_ID", "target" ], "value": [ "owwL79CHWdDD", "gi9BFSpLY1nj" ], "valueType": "string", "renderType": "reference" } ] } ], "outputs": [] }, { "nodeId": "sFeHXAx2b2Vs", "name": "AI 对话", "intro": "AI 大模型对话", "avatar": "core/workflow/template/aiChat", "flowNodeType": "chatNode", "showStatus": true, "position": { "x": 3038.5121928842154, "y": 59.09803763616847 }, "version": "481", "inputs": [ { "key": "model", "renderTypeList": [ "settingLLMModel", "reference" ], "label": "core.module.input.label.aiModel", "valueType": "string", "value": "gpt-4o-mini" }, { "key": "temperature", "renderTypeList": [ "hidden" ], "label": "", "value": 0, "valueType": "number" }, { "key": "maxToken", "renderTypeList": [ "hidden" ], "label": "", "value": 2000, "valueType": "number" }, { "key": "isResponseAnswerText", "renderTypeList": [ "hidden" ], "label": "", "value": true, "valueType": "boolean" }, { "key": "quoteTemplate", "renderTypeList": [ "hidden" ], "label": "", "valueType": "string" }, { "key": "quotePrompt", "renderTypeList": [ "hidden" ], "label": "", "valueType": "string" }, { "key": "aiChatVision", "renderTypeList": [ "hidden" ], "label": "", "valueType": "boolean", "value": true }, { "key": "systemPrompt", "renderTypeList": [ "textarea", "reference" ], "max": 3000, "valueType": "string", "label": "core.ai.Prompt", "description": "core.app.tip.chatNodeSystemPromptTip", "placeholder": "core.app.tip.chatNodeSystemPromptTip", "value": "用户目的地是:{{$VARIABLE_NODE_ID.target$}}\n用户的旅行天数是{{$VARIABLE_NODE_ID.days$}}\n如果上述信息为空,你需要通过提问获取信息\n" }, { "key": "history", "renderTypeList": [ "numberInput", "reference" ], "valueType": "chatHistory", "label": "core.module.input.label.chat history", "description": "最多携带多少轮对话记录", "required": true, "min": 0, "max": 50, "value": 0 }, { "key": "quoteQA", "renderTypeList": [ "settingDatasetQuotePrompt" ], "label": "", "debugLabel": "知识库引用", "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": "用户问题", "required": true, "toolDescription": "用户问题", "value": [ "448745", "userChatInput" ] } ], "outputs": [ { "id": "history", "key": "history", "required": true, "label": "core.module.output.label.New context", "description": "core.module.output.description.New context", "valueType": "chatHistory", "type": "static" }, { "id": "answerText", "key": "answerText", "required": true, "label": "core.module.output.label.Ai response content", "description": "core.module.output.description.Ai response content", "valueType": "string", "type": "static" } ] }, { "nodeId": "owwL79CHWdDD", "name": "文本内容提取", "intro": "可从文本中提取指定的数据,例如:sql语句、搜索关键词、代码等", "avatar": "core/workflow/template/extractJson", "flowNodeType": "contentExtract", "showStatus": true, "position": { "x": 987.0370712605812, "y": 90.71983265598982 }, "version": "481", "inputs": [ { "key": "model", "renderTypeList": [ "selectLLMModel", "reference" ], "label": "core.module.input.label.aiModel", "required": true, "valueType": "string", "llmModelType": "extractFields", "value": "gpt-4o-mini" }, { "key": "description", "renderTypeList": [ "textarea", "reference" ], "valueType": "string", "label": "提取要求描述", "description": "给AI一些对应的背景知识或要求描述,引导AI更好的完成任务。\n该输入框可使用全局变量。", "placeholder": "例如: \n1. 当前时间为: {{cTime}}。你是一个实验室预约助手,你的任务是帮助用户预约实验室,从文本中获取对应的预约信息。\n2. 你是谷歌搜索助手,需要从文本中提取出合适的搜索词。", "value": "用户目的地是:{{$VARIABLE_NODE_ID.target$}}\n用户的旅行天数是{{$VARIABLE_NODE_ID.days$}}\n如果需要从输入的文本中提取信息替代上面的信息" }, { "key": "history", "renderTypeList": [ "numberInput", "reference" ], "valueType": "chatHistory", "label": "core.module.input.label.chat history", "description": "最多携带多少轮对话记录", "required": true, "min": 0, "max": 50, "value": 6 }, { "key": "content", "renderTypeList": [ "reference", "textarea" ], "label": "需要提取的文本", "required": true, "valueType": "string", "toolDescription": "需要检索的内容", "value": [ "448745", "userChatInput" ] }, { "key": "extractKeys", "renderTypeList": [ "custom" ], "label": "", "valueType": "any", "description": "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段", "value": [ { "valueType": "string", "required": false, "defaultValue": "", "desc": "用户旅游的目的地", "key": "target", "enum": "" }, { "valueType": "string", "required": false, "defaultValue": "", "desc": "旅游的天数", "key": "days", "enum": "" } ] } ], "outputs": [ { "id": "success", "key": "success", "label": "字段完全提取", "required": true, "description": "提取字段全部填充时返回 true (模型提取或使用默认值均属于成功)", "valueType": "boolean", "type": "static" }, { "id": "fields", "key": "fields", "label": "完整提取结果", "required": true, "description": "一个 JSON 字符串,例如:{\"name:\":\"YY\",\"Time\":\"2023/7/2 18:00\"}", "valueType": "string", "type": "static" }, { "id": "gi9BFSpLY1nj", "key": "target", "label": "提取结果-用户旅游的目的地", "valueType": "string", "type": "static" }, { "id": "uLiCRPjyItaX", "key": "days", "label": "提取结果-旅游的天数", "valueType": "string", "type": "static" } ] }, { "nodeId": "mi9g6NPe5Qri", "name": "判断器", "intro": "根据一定的条件,执行不同的分支。", "avatar": "core/workflow/template/ifelse", "flowNodeType": "ifElseNode", "showStatus": true, "position": { "x": 1631.3534237880635, "y": -425.87340444891225 }, "version": "481", "inputs": [ { "key": "ifElseList", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "", "value": [ { "condition": "AND", "list": [ { "variable": [ "owwL79CHWdDD", "gi9BFSpLY1nj" ], "condition": "isNotEmpty" } ] } ] } ], "outputs": [ { "id": "ifElseResult", "key": "ifElseResult", "label": "判断结果", "valueType": "string", "type": "static" } ] }, { "nodeId": "h1TxF3QNcush", "name": "判断器#2", "intro": "根据一定的条件,执行不同的分支。", "avatar": "core/workflow/template/ifelse", "flowNodeType": "ifElseNode", "showStatus": true, "position": { "x": 1585.912398395383, "y": 161.88378154359145 }, "version": "481", "inputs": [ { "key": "ifElseList", "renderTypeList": [ "hidden" ], "valueType": "any", "label": "", "value": [ { "condition": "AND", "list": [ { "variable": [ "owwL79CHWdDD", "uLiCRPjyItaX" ], "condition": "isNotEmpty" } ] } ] } ], "outputs": [ { "id": "ifElseResult", "key": "ifElseResult", "label": "判断结果", "valueType": "string", "type": "static" } ] }, { "nodeId": "xaX3RUAk6tud", "name": "变量更新#2", "intro": "可以更新指定节点的输出值或更新全局变量", "avatar": "core/workflow/template/variableUpdate", "flowNodeType": "variableUpdate", "showStatus": false, "position": { "x": 2461.01421150823, "y": 88.31608974152292 }, "version": "481", "inputs": [ { "key": "updateList", "valueType": "any", "label": "", "renderTypeList": [ "hidden" ], "value": [ { "variable": [ "VARIABLE_NODE_ID", "days" ], "value": [ "owwL79CHWdDD", "uLiCRPjyItaX" ], "valueType": "string", "renderType": "reference" } ] } ], "outputs": [] } ], "edges": [ { "source": "448745", "target": "owwL79CHWdDD", "sourceHandle": "448745-source-right", "targetHandle": "owwL79CHWdDD-target-left" }, { "source": "owwL79CHWdDD", "target": "mi9g6NPe5Qri", "sourceHandle": "owwL79CHWdDD-source-right", "targetHandle": "mi9g6NPe5Qri-target-left" }, { "source": "mi9g6NPe5Qri", "target": "y3B4gjlLbTz7", "sourceHandle": "mi9g6NPe5Qri-source-IF", "targetHandle": "y3B4gjlLbTz7-target-left" }, { "source": "owwL79CHWdDD", "target": "h1TxF3QNcush", "sourceHandle": "owwL79CHWdDD-source-right", "targetHandle": "h1TxF3QNcush-target-left" }, { "source": "h1TxF3QNcush", "target": "xaX3RUAk6tud", "sourceHandle": "h1TxF3QNcush-source-IF", "targetHandle": "xaX3RUAk6tud-target-left" }, { "source": "xaX3RUAk6tud", "target": "sFeHXAx2b2Vs", "sourceHandle": "xaX3RUAk6tud-source-right", "targetHandle": "sFeHXAx2b2Vs-target-left" }, { "source": "h1TxF3QNcush", "target": "sFeHXAx2b2Vs", "sourceHandle": "h1TxF3QNcush-source-ELSE", "targetHandle": "sFeHXAx2b2Vs-target-left" } ], "chatConfig": { "scheduledTriggerConfig": { "cronString": "", "timezone": "Asia/Shanghai", "defaultPrompt": "" }, "variables": [ { "id": "7gm1hc", "key": "target", "label": "target", "type": "custom", "required": false, "maxLen": 50, "enums": [ { "value": "" } ], "icon": "core/app/variable/input" }, { "id": "u58hs7", "key": "days", "label": "days", "type": "custom", "required": false, "maxLen": 50, "enums": [ { "value": "" } ], "icon": "core/app/variable/input" } ] } }

anomone commented 1 month ago

从客户体验来说还不如用全局变量收集或者一次性问完呢,其实直接放在prompt提问里也可以。 按你的要求也不是不行,就是比较复杂而且浪费时间: image

受您的启发,通过判断器、变量更新 和 代码执行已经实现了,非常感谢。 就是对话开场白不能分成两段,流程发起总是用户,不能是ai方,开场白效果有点勉强

image

加了这一段 image

效果相当Nice,fastgpt牛逼