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

本次使用到的工具:

FastGPT
AFF 硅基流动 含aff

首先介绍一下

FastGPT提供开箱即用的数据处理和模型调用能力。它支持通过可视化的 Flow 模块进行工作流编排,以实现复杂的问答场景。FASTGPT基本使用教程B站有,可以去看看,这里不做讲解。

FASTGPT各个模型会优先调用用户自己的配置的接口,若无,才会消耗FASTGPT的AI积分进行调用。因此,FASTGPT基本只消耗一些索引的token,消耗极少,在免费范围内。FASTGPT配置的接口也可以选用 AFF 硅基流动 含aff的deepseekchat模型。

AFF 硅基流动 含aff 拉新双方可领取2000万token,可以调用deepseek chat,并且可以免费调用FLUX.1模型绘画。FLUX.1应该是目前最强绘画模型。
AI 绘画新标杆!一文详解最新开源模型 Flux.1

综上,无任何付费项目。

效果展示:


直接输入中文提示词即可,会生成对应英文提示词

工作流展示:

部署教程:

先在 AFF 硅基流动 含aff中注册,生成api key,复制备用。
image

接着去fastgpt创建工作流,并导入我的工作流如下:

{
  "nodes": [
    {
      "nodeId": "userGuide",
      "name": "core.module.template.User guide",
      "intro": "core.app.tip.userGuideTip",
      "avatar": "core/workflow/template/systemConfig",
      "flowNodeType": "userGuide",
      "position": {
        "x": 638.9689284902843,
        "y": 1330.8896334960516
      },
      "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": 1046.1768900426205,
        "y": 1422.528457769088
      },
      "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": 1461.3899581366866,
        "y": 1164.185941848274
      },
      "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": 3,
          "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\"、\"4k\"这样的标签可以提高图像的细节。像\"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, 4k, 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": 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": [
            "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",
          "valueDesc": "{\n  obj: System | Human | AI;\n  value: string;\n}[]",
          "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": 2097.395110695174,
        "y": 1268.0575222390357
      },
      "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_httpTimeout",
          "renderTypeList": [
            "custom"
          ],
          "valueType": "number",
          "label": "",
          "value": 30,
          "min": 5,
          "max": 600,
          "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-xxxxx"
            }
          ],
          "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\": \"1024x1024\",\r\n  \"num_inference_steps\": 28\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
          }
        }
      ],
      "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": 2734.785397176285,
        "y": 1410.7360523031057
      },
      "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": "userChatInput",
      "target": "tNbjIPgU4HWr",
      "sourceHandle": "userChatInput-source-right",
      "targetHandle": "tNbjIPgU4HWr-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"
    }
  ],
  "chatConfig": {
    "welcomeText": "您好,我是FLUX.1 AI绘画小助手.\n\n直接输入提示词即可使用AI绘画。AI自动优化提示词",
    "variables": [],
    "whisperConfig": {
      "open": true,
      "autoSend": false,
      "autoTTSResponse": false
    },
    "scheduledTriggerConfig": {
      "cronString": "",
      "timezone": "Asia/Shanghai",
      "defaultPrompt": ""
    },
    "_id": "66c4a5e9501b65de6749f604"
  }
}

导入方式如下:

接着来到图中所示空处,将sk-xxxxxxx换成你的之前提到的api kay

(可选)以上工作流调用的是FLUX.1,如果想使用SD3绘画的话,在上图中,点击cURL导入,输入以下内容即可:

curl --request POST \
     --url https://api.siliconflow.cn/v1/stabilityai/stable-diffusion-3-medium/text-to-image \
     --header 'accept: application/json' \
     --header 'authorization: Bearer sk-xxxxxxxxx' \
     --header 'content-type: application/json' \
     --data '
{
  "prompt": "{{prompt}}",
  "image_size": "1024x1024",
  "batch_size": 1,
  "num_inference_steps": 20,
  "guidance_scale": 7.5
}
'

接入NEW API

在fastgpt点击发布渠道,然后记录下图中两个红框的值,另外发布渠道中也可以直接创建我下面那样的分享链接

来到NEW API填写相关信息即可,兼容open ai接口

大功告成

这是我搭建好的,大家可以试试:效果展示 (已屏蔽nsfw的内容)

鸣谢

参考: 放一个fastgpt调用CF的SD模型并结合gpt的简单绘图工作流,让大佬们看看哪里可以进行优化 - 常规话题 / 快问快答 - LINUX DO

搭建图生图的工作流:

【2】一分钱不花! AI图生图,AI优化生成提示词,并可接入NEW API,模型工具全免费,永久有效 - 常规话题 / 人工智能 - LINUX DO

542 个赞

学到了,感谢分享

5 个赞

谢谢分享!!感觉在改改可以做推文,或者绘本

3 个赞

收藏吃灰 学习 :herb:

6 个赞

不错,我是本地用 python 做了转换

5 个赞

哈哈哈哈,厉害厉害

7 个赞

大佬厉害,也出个教程

2 个赞

全都是硅基的aff。。。

6 个赞

都怪奖励太丰厚

3 个赞

不错的想法,一句话生成完整漫画那种?

3 个赞

感谢大佬,学习一下

7 个赞

点点AFF,谢谢大家,互利

1 个赞

强,太强了,试一下

4 个赞

感谢分享 :heart:

2 个赞

上午还在研究,下午大佬就整出来了,666

3 个赞

感谢分享,收藏了

6 个赞

2 个赞

markmark

5 个赞

感谢分享,mark

2 个赞

秀儿哇,就是有点慢,半天不出图

4 个赞