【Fastgpt系列1】一分钱不花 搭建AI自动优化生成提示词 调用FLUX.1绘画,并可接入NEW API

正想接入newapi感谢教程

2 个赞

装 fastgpt 要多大内存? 印象中是 16G, 再找官方文档又没看见哪里写了

6 个赞

收藏学习, :+1: 虽然大概率吃灰了

1 个赞

想起来了,因为 nextchat 右键被用作复制文本到编辑区的快捷方式了,所以我才加了下载链接,方便点击下载哈哈 tieba2

2 个赞

厉害了,我的佬

1 个赞

新增选择尺寸的小功能,工作流如下,复制导入即可
网页分享可用

{
  "nodes": [
    {
      "nodeId": "userGuide",
      "name": "core.module.template.User guide",
      "intro": "core.app.tip.userGuideTip",
      "avatar": "core/workflow/template/systemConfig",
      "flowNodeType": "userGuide",
      "position": {
        "x": 1206.7315739394317,
        "y": 966.06330314574
      },
      "version": "481",
      "inputs": [
        {
          "key": "welcomeText",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "string",
          "label": "core.app.Welcome Text",
          "type": "hidden",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "value": "您好,我是stable-diffusion文生图像绘制助手,您可以按照下面这个格式进行提问:\n[一只赛博朋克猫咪]\n[一只黑白相间的狗在追蝴蝶]",
          "connected": false,
          "selectedTypeIndex": 0
        },
        {
          "key": "variables",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "label": "core.module.Variable",
          "value": [
            {
              "id": "6agumx",
              "key": "AI优化",
              "label": "是否需要使用AI优化提示词?(默认不需要)",
              "type": "select",
              "required": false,
              "maxLen": 50,
              "enums": [
                {
                  "value": "true"
                },
                {
                  "value": "false"
                }
              ],
              "icon": "core/app/variable/select"
            }
          ],
          "type": "hidden",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "connected": false,
          "selectedTypeIndex": 0
        },
        {
          "key": "questionGuide",
          "valueType": "boolean",
          "renderTypeList": [
            "hidden"
          ],
          "label": "",
          "type": "switch",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "connected": false,
          "selectedTypeIndex": 0
        },
        {
          "key": "tts",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "label": "",
          "type": "hidden",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "connected": false,
          "selectedTypeIndex": 0
        },
        {
          "key": "whisper",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "label": "",
          "type": "hidden",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "connected": false,
          "selectedTypeIndex": 0
        },
        {
          "key": "scheduleTrigger",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "label": "",
          "value": null
        }
      ],
      "outputs": []
    },
    {
      "nodeId": "userChatInput",
      "name": "流程开始",
      "intro": "当用户发送一个内容后,流程将会从这个模块开始执行。",
      "avatar": "core/workflow/template/workflowStart",
      "flowNodeType": "workflowStart",
      "position": {
        "x": 1303.5627485971718,
        "y": 1755.3738090342488
      },
      "version": "481",
      "inputs": [
        {
          "key": "userChatInput",
          "renderTypeList": [
            "reference",
            "textarea"
          ],
          "valueType": "string",
          "label": "问题输入",
          "required": true,
          "toolDescription": "用户问题",
          "type": "systemInput",
          "showTargetInApp": false,
          "showTargetInPlugin": false,
          "connected": false,
          "selectedTypeIndex": 0,
          "value": [
            "userChatInput",
            "userChatInput"
          ]
        }
      ],
      "outputs": [
        {
          "id": "userChatInput",
          "key": "userChatInput",
          "label": "common:core.module.input.label.user question",
          "type": "static",
          "valueType": "string"
        }
      ]
    },
    {
      "nodeId": "tNbjIPgU4HWr",
      "name": "AI 生成提示词",
      "intro": "AI 大模型对话",
      "avatar": "core/workflow/template/aiChat",
      "flowNodeType": "chatNode",
      "showStatus": true,
      "position": {
        "x": 1709.4427657797612,
        "y": 1226.0026796559307
      },
      "version": "481",
      "inputs": [
        {
          "key": "model",
          "renderTypeList": [
            "settingLLMModel",
            "reference"
          ],
          "label": "core.module.input.label.aiModel",
          "valueType": "string",
          "value": "deepseek-chat"
        },
        {
          "key": "temperature",
          "renderTypeList": [
            "hidden"
          ],
          "label": "",
          "value": 0,
          "valueType": "number",
          "min": 0,
          "max": 10,
          "step": 1
        },
        {
          "key": "maxToken",
          "renderTypeList": [
            "hidden"
          ],
          "label": "",
          "value": 4000,
          "valueType": "number",
          "min": 100,
          "max": 4000,
          "step": 50
        },
        {
          "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": "作为 Stable Diffusion Prompt 提示词专家,您将从关键词中创建提示,通常来自 Danbooru 等数据库。\n\n提示通常描述图像,使用常见词汇,按重要性排列,并用逗号分隔。避免使用\"-\"或\".\",但可以接受空格和自然语言。避免词汇重复。\n\n为了强调关键词,请将其放在括号中以增加其权重。例如,\"(flowers)\"将'flowers'的权重增加1.1倍,而\"(((flowers)))\"将其增加1.331倍。使用\"(flowers:1.5)\"将'flowers'的权重增加1.5倍。只为重要的标签增加权重。\n\n提示包括三个部分:**前缀**(质量标签+风格词+效果器)+ **主题**(图像的主要焦点)+ **场景**(背景、环境)。\n\n*   前缀影响图像质量。像\"masterpiece\"、\"best quality\"这样的标签可以提高图像的细节。像\"illustration\"、\"lensflare\"这样的风格词定义图像的风格。像\"bestlighting\"、\"lensflare\"、\"depthoffield\"这样的效果器会影响光照和深度。\n\n*   主题是图像的主要焦点,如角色或场景。对主题进行详细描述可以确保图像丰富而详细。增加主题的权重以增强其清晰度。对于角色,描述面部、头发、身体、服装、姿势等特征。\n\n*   场景描述环境。没有场景,图像的背景是平淡的,主题显得过大。某些主题本身包含场景(例如建筑物、风景)。像\"花草草地\"、\"阳光\"、\"河流\"这样的环境词可以丰富场景。你的任务是设计图像生成的提示。请按照以下步骤进行操作:\n\n1.  我会发送给您一个图像场景。需要你生成详细的图像描述\n2.  图像描述必须是英文,输出为Positive Prompt。\n\n示例:\n\n我发送:二战时期的护士。\n您回复只回复:\nA WWII-era nurse in a German uniform, holding a wine bottle and stethoscope, sitting at a table in white attire, with a table in the background, masterpiece, best quality, illustration style, best lighting, depth of field, detailed character, detailed environment.\n"
        },
        {
          "key": "history",
          "renderTypeList": [
            "numberInput",
            "reference"
          ],
          "valueType": "chatHistory",
          "label": "core.module.input.label.chat history",
          "description": "最多携带多少轮对话记录",
          "required": true,
          "min": 0,
          "max": 50,
          "value": 1
        },
        {
          "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": [
            "userChatInput",
            "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": "szqvHMArA7rG",
      "name": "FLUX.1",
      "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
      "avatar": "core/workflow/template/httpRequest",
      "flowNodeType": "httpRequest468",
      "showStatus": true,
      "position": {
        "x": 2371.3283546123544,
        "y": 1275.0219267454047
      },
      "version": "481",
      "inputs": [
        {
          "key": "system_addInputParam",
          "renderTypeList": [
            "addInputParam"
          ],
          "valueType": "dynamic",
          "label": "",
          "required": false,
          "description": "core.module.input.description.HTTP Dynamic Input",
          "editField": {
            "key": true,
            "valueType": true
          },
          "customInputConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": true
          }
        },
        {
          "key": "system_httpMethod",
          "renderTypeList": [
            "custom"
          ],
          "valueType": "string",
          "label": "",
          "value": "POST",
          "required": true
        },
        {
          "key": "system_httpReqUrl",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "string",
          "label": "",
          "description": "core.module.input.description.Http Request Url",
          "placeholder": "https://api.ai.com/getInventory",
          "required": false,
          "value": "https://api.siliconflow.cn/v1/black-forest-labs/FLUX.1-schnell/text-to-image"
        },
        {
          "key": "system_httpHeader",
          "renderTypeList": [
            "custom"
          ],
          "valueType": "any",
          "value": [
            {
              "key": "content-type",
              "type": "string",
              "value": "application/json"
            },
            {
              "key": "authorization",
              "type": "string",
              "value": "Bearer sk-xxxxxx"
            }
          ],
          "label": "",
          "description": "core.module.input.description.Http Request Header",
          "placeholder": "core.module.input.description.Http Request Header",
          "required": false
        },
        {
          "key": "system_httpParams",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "value": [],
          "label": "",
          "required": false
        },
        {
          "key": "system_httpJsonBody",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "value": "{\r\n  \"prompt\": \"{{prompt}}\",\r\n  \"image_size\": \"{{size}}\",\r\n  \"num_inference_steps\": 20\r\n}",
          "label": "",
          "required": false
        },
        {
          "key": "prompt",
          "valueType": "string",
          "label": "prompt",
          "renderTypeList": [
            "reference"
          ],
          "description": "",
          "canEdit": true,
          "editField": {
            "key": true,
            "valueType": true
          },
          "value": [
            "tNbjIPgU4HWr",
            "answerText"
          ],
          "customInputConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": true
          }
        },
        {
          "renderTypeList": [
            "reference"
          ],
          "valueType": "string",
          "canEdit": true,
          "key": "size",
          "label": "size",
          "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",
            "1024x1024"
          ]
        }
      ],
      "outputs": [
        {
          "id": "error",
          "key": "error",
          "label": "请求错误",
          "description": "HTTP请求错误信息,成功时返回空",
          "valueType": "object",
          "type": "static"
        },
        {
          "id": "httpRawResponse",
          "key": "httpRawResponse",
          "label": "原始响应",
          "required": true,
          "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
          "valueType": "any",
          "type": "static"
        },
        {
          "id": "system_addOutputParam",
          "key": "system_addOutputParam",
          "type": "dynamic",
          "valueType": "dynamic",
          "label": "",
          "editField": {
            "key": true,
            "valueType": true
          }
        },
        {
          "id": "q2mkKEFTiGJV",
          "type": "dynamic",
          "key": "images[0].url",
          "valueType": "string",
          "label": "images[0].url"
        }
      ]
    },
    {
      "nodeId": "vFlAtLTLYxl7",
      "name": "文本拼接",
      "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
      "avatar": "core/workflow/template/textConcat",
      "flowNodeType": "textEditor",
      "position": {
        "x": 2910.193391106812,
        "y": 1384.9407590780281
      },
      "version": "486",
      "inputs": [
        {
          "key": "system_addInputParam",
          "renderTypeList": [
            "addInputParam"
          ],
          "valueType": "dynamic",
          "label": "",
          "required": false,
          "description": "可以引用其他节点的输出,作为文本拼接的变量,通过 {{字段名}} 来引用变量",
          "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": "拼接文本",
          "placeholder": "可通过 {{字段名}} 来引用变量",
          "value": "![ai]({{url}})"
        },
        {
          "renderTypeList": [
            "reference"
          ],
          "valueType": "string",
          "canEdit": true,
          "key": "url",
          "label": "url",
          "customInputConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": false
          },
          "required": true,
          "value": [
            "szqvHMArA7rG",
            "q2mkKEFTiGJV"
          ]
        }
      ],
      "outputs": [
        {
          "id": "system_text",
          "key": "system_text",
          "label": "拼接结果",
          "type": "static",
          "valueType": "string"
        }
      ]
    },
    {
      "nodeId": "e6s2QseLaH23",
      "name": "指定回复",
      "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
      "avatar": "core/workflow/template/reply",
      "flowNodeType": "answerNode",
      "position": {
        "x": 3270.1509500165303,
        "y": 1596.8386061773158
      },
      "version": "481",
      "inputs": [
        {
          "key": "text",
          "renderTypeList": [
            "textarea",
            "reference"
          ],
          "valueType": "any",
          "required": true,
          "label": "core.module.input.label.Response content",
          "description": "core.module.input.description.Response content",
          "placeholder": "core.module.input.description.Response content",
          "selectedTypeIndex": 1,
          "value": [
            "vFlAtLTLYxl7",
            "system_text"
          ]
        }
      ],
      "outputs": []
    }
  ],
  "edges": [
    {
      "source": "tNbjIPgU4HWr",
      "target": "szqvHMArA7rG",
      "sourceHandle": "tNbjIPgU4HWr-source-right",
      "targetHandle": "szqvHMArA7rG-target-left"
    },
    {
      "source": "vFlAtLTLYxl7",
      "target": "e6s2QseLaH23",
      "sourceHandle": "vFlAtLTLYxl7-source-right",
      "targetHandle": "e6s2QseLaH23-target-left"
    },
    {
      "source": "szqvHMArA7rG",
      "target": "vFlAtLTLYxl7",
      "sourceHandle": "szqvHMArA7rG-source-right",
      "targetHandle": "vFlAtLTLYxl7-target-left"
    },
    {
      "source": "userChatInput",
      "target": "tNbjIPgU4HWr",
      "sourceHandle": "userChatInput-source-right",
      "targetHandle": "tNbjIPgU4HWr-target-left"
    }
  ],
  "chatConfig": {
    "welcomeText": "您好,我是FLUX.1 AI绘画小助手.\n\n直接输入提示词(中英文均可)即可使用AI绘画。AI自动优化提示词",
    "variables": [
      {
        "id": "wewqas",
        "key": "1024x1024",
        "label": "选择图像尺寸",
        "type": "select",
        "required": true,
        "maxLen": 50,
        "enums": [
          {
            "value": "1024x1024"
          },
          {
            "value": "1024x576"
          },
          {
            "value": "576x1024"
          }
        ],
        "icon": "core/app/variable/select"
      }
    ],
    "whisperConfig": {
      "open": true,
      "autoSend": false,
      "autoTTSResponse": false
    },
    "scheduledTriggerConfig": {
      "cronString": "",
      "timezone": "Asia/Shanghai",
      "defaultPrompt": ""
    },
    "_id": "66c4a5e9501b65de6749f604"
  }
}
4 个赞

跑起来了,速度很快

2 个赞

好久没研究这个了

1 个赞

我好像错过了一堆事情

1 个赞

感谢分享,有两个问题
1.fastgpt可以用自己的api来生成提示词吗?
2.在lobe chat似乎不能正常返回结果,回复是空白

2 个赞

不错不错!!

1 个赞

非常感谢,正愁着找不到接口

fastgpt可以用自己的api来生成提示词
配置好openai接口即可

lobe chat理论上可以正常用

3 个赞

已经搞定了,感谢
另外我发现用的是FLUX.1-schnell,为什么不是用dev模型呢,似乎效果要好一点吧

硅基暂未提供dev模型,而且dev模型不允许商用

2 个赞

对对对,那这个应该咋整呢?敢问大佬你这个怎么弄的?

12 个赞

改成这样就行了

2 个赞

真牛逼,感谢

4 个赞

大佬,这个图片好大呀,这个里面可以改尺寸的嘛,你看,大佬。


改"image_size"的值就行,如 1024x1024 稍微大点AI绘画的精细点

3 个赞