【Fastgpt系列2】一分钱不花! AI图生图,AI优化生成提示词,并可接入NEW API,永久免费

前情提要:

一分钱不花! 搭建AI自动优化生成提示词 后调用FLUX.1或者SD3 AI绘画,并可接入NEW API,模型工具全免费,永久有效 - 常规话题 / 人工智能 - LINUX DO

本次使用到的工具:

FastGPT
AFF 硅基流动 含aff
Cloudflare 大善人的worker

首先介绍一下

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
还可以免费调用SDXL图生图模型。

Cloudflare 大善人的worker用于搭建 img to base64 的功能
如实在不会搭建 img to base64 的功能的话,也可以直接使用我搭建的,复制工作流导入即可

综上,无任何付费项目。

效果展示:

工作流展示:

工作流导入:

{
  "nodes": [
    {
      "nodeId": "userGuide",
      "name": "core.module.template.User guide",
      "intro": "core.app.tip.userGuideTip",
      "avatar": "core/workflow/template/systemConfig",
      "flowNodeType": "userGuide",
      "position": {
        "x": 2806.440723630102,
        "y": 2213.8764751163535
      },
      "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": 1687.1273916672578,
        "y": 1617.973743517647
      },
      "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"
        },
        {
          "id": "userFiles",
          "key": "userFiles",
          "label": "app:workflow.user_file_input",
          "description": "app:workflow.user_file_input_desc",
          "type": "static",
          "valueType": "arrayString"
        }
      ]
    },
    {
      "nodeId": "tNbjIPgU4HWr",
      "name": "AI 生成提示词",
      "intro": "AI 大模型对话",
      "avatar": "core/workflow/template/aiChat",
      "flowNodeType": "chatNode",
      "showStatus": true,
      "position": {
        "x": 2083.051608390704,
        "y": 1369.3070768509804
      },
      "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": 2,
          "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",
          "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": "vFlAtLTLYxl7",
      "name": "文本拼接",
      "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
      "avatar": "core/workflow/template/textConcat",
      "flowNodeType": "textEditor",
      "position": {
        "x": 4031.751927125333,
        "y": 1464.5370429172842
      },
      "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": "\n![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": [
            "uHkZxdjD51fW",
            "ozxYHsrGitKE"
          ]
        }
      ],
      "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": 4593.058707050784,
        "y": 1640.0370429172842
      },
      "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": []
    },
    {
      "nodeId": "uHkZxdjD51fW",
      "name": "FLUX.1 AI绘画中",
      "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
      "avatar": "core/workflow/template/httpRequest",
      "flowNodeType": "httpRequest468",
      "showStatus": true,
      "position": {
        "x": 3511.409585773052,
        "y": 1271.0370429172842
      },
      "version": "481",
      "inputs": [
        {
          "key": "system_addInputParam",
          "renderTypeList": [
            "addInputParam"
          ],
          "valueType": "dynamic",
          "label": "",
          "required": false,
          "description": "core.module.input.description.HTTP Dynamic Input",
          "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": "accept",
              "value": "application/json",
              "type": "string"
            },
            {
              "key": "authorization",
              "value": "Bearer sk-xxxxxxxxx",
              "type": "string"
            },
            {
              "key": "content-type",
              "value": "application/json",
              "type": "string"
            }
          ],
          "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": "{\n  \"prompt\": \"{{prompt}}\",\n  \"image_size\": \"{{size}}\",\n  \"num_inference_steps\": 28\n}",
          "label": "",
          "required": false
        },
        {
          "renderTypeList": [
            "reference"
          ],
          "valueType": "string",
          "canEdit": true,
          "key": "prompt",
          "label": "prompt",
          "customInputConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": true
          },
          "required": true,
          "value": [
            "tNbjIPgU4HWr",
            "answerText"
          ]
        },
        {
          "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": "",
          "customFieldConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": false
          }
        },
        {
          "id": "ozxYHsrGitKE",
          "valueType": "string",
          "type": "dynamic",
          "key": "images[0].url",
          "label": "images[0].url"
        }
      ]
    },
    {
      "nodeId": "aQ5IQRj8Smuo",
      "name": "判断器",
      "intro": "根据一定的条件,执行不同的分支。",
      "avatar": "core/workflow/template/ifelse",
      "flowNodeType": "ifElseNode",
      "showStatus": true,
      "position": {
        "x": 2694.256451376145,
        "y": 1640.0370429172842
      },
      "version": "481",
      "inputs": [
        {
          "key": "ifElseList",
          "renderTypeList": [
            "hidden"
          ],
          "valueType": "any",
          "label": "",
          "value": [
            {
              "condition": "AND",
              "list": [
                {
                  "variable": [
                    "VARIABLE_NODE_ID",
                    "否"
                  ],
                  "condition": "equalTo",
                  "value": "否"
                }
              ]
            }
          ]
        }
      ],
      "outputs": [
        {
          "id": "ifElseResult",
          "key": "ifElseResult",
          "label": "判断结果",
          "valueType": "string",
          "type": "static"
        }
      ]
    },
    {
      "nodeId": "eobfPJ74NcFt",
      "name": "base64编码",
      "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
      "avatar": "core/workflow/template/httpRequest",
      "flowNodeType": "httpRequest468",
      "showStatus": true,
      "position": {
        "x": 3511.409585773052,
        "y": 2406.8701256209265
      },
      "version": "481",
      "inputs": [
        {
          "key": "system_addInputParam",
          "renderTypeList": [
            "addInputParam"
          ],
          "valueType": "dynamic",
          "label": "",
          "required": false,
          "description": "core.module.input.description.HTTP Dynamic Input",
          "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://sd.281625263.workers.dev"
        },
        {
          "key": "system_httpHeader",
          "renderTypeList": [
            "custom"
          ],
          "valueType": "any",
          "value": [
            {
              "key": "content-type",
              "value": "application/json",
              "type": "string"
            }
          ],
          "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": "{\n \"url\": \"{{url}}\" \n}",
          "label": "",
          "required": false
        },
        {
          "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": true
          },
          "required": true,
          "value": [
            "VARIABLE_NODE_ID",
            "1024"
          ]
        }
      ],
      "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": "",
          "customFieldConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": false
          }
        },
        {
          "id": "ozxYHsrGitKE",
          "valueType": "string",
          "type": "dynamic",
          "key": "dataUrl",
          "label": "dataUrl"
        }
      ]
    },
    {
      "nodeId": "sEKrNvlLofIK",
      "name": "文本拼接#2",
      "intro": "可对固定或传入的文本进行加工后输出,非字符串类型数据最终会转成字符串类型。",
      "avatar": "core/workflow/template/textConcat",
      "flowNodeType": "textEditor",
      "position": {
        "x": 4622.983100908259,
        "y": 2139.977466464875
      },
      "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": "\n![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": [
            "z02LIp9riLnG",
            "ozxYHsrGitKE"
          ]
        }
      ],
      "outputs": [
        {
          "id": "system_text",
          "key": "system_text",
          "label": "拼接结果",
          "type": "static",
          "valueType": "string"
        }
      ]
    },
    {
      "nodeId": "xiuk1fLEBlE7",
      "name": "指定回复#2",
      "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
      "avatar": "core/workflow/template/reply",
      "flowNodeType": "answerNode",
      "position": {
        "x": 4678.942715175715,
        "y": 2880.810799798208
      },
      "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": [
            "sEKrNvlLofIK",
            "system_text"
          ]
        }
      ],
      "outputs": []
    },
    {
      "nodeId": "z02LIp9riLnG",
      "name": "SDXL AI绘画中",
      "intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
      "avatar": "core/workflow/template/httpRequest",
      "flowNodeType": "httpRequest468",
      "showStatus": true,
      "position": {
        "x": 4071.751927125333,
        "y": 2101.996154226935
      },
      "version": "481",
      "inputs": [
        {
          "key": "system_addInputParam",
          "renderTypeList": [
            "addInputParam"
          ],
          "valueType": "dynamic",
          "label": "",
          "required": false,
          "description": "core.module.input.description.HTTP Dynamic Input",
          "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/stabilityai/stable-diffusion-xl-base-1.0/image-to-image"
        },
        {
          "key": "system_httpHeader",
          "renderTypeList": [
            "custom"
          ],
          "valueType": "any",
          "value": [
            {
              "key": "accept",
              "value": "application/json",
              "type": "string"
            },
            {
              "key": "authorization",
              "value": "Bearer sk-xxxxxxxxxx",
              "type": "string"
            },
            {
              "key": "content-type",
              "value": "application/json",
              "type": "string"
            }
          ],
          "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": "{\n  \"prompt\": \"{{prompt}}\",\n  \"image\": \"{{url}}\",\n  \"image_size\": \"{{size}}\",\n  \"batch_size\": 1,\n  \"num_inference_steps\": 30,\n  \"guidance_scale\": 7.5\n}",
          "label": "",
          "required": false
        },
        {
          "renderTypeList": [
            "reference"
          ],
          "valueType": "string",
          "canEdit": true,
          "key": "prompt",
          "label": "prompt",
          "customInputConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": true
          },
          "required": true,
          "value": [
            "tNbjIPgU4HWr",
            "answerText"
          ]
        },
        {
          "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"
          ]
        },
        {
          "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": true
          },
          "required": true,
          "value": [
            "eobfPJ74NcFt",
            "ozxYHsrGitKE"
          ]
        }
      ],
      "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": "",
          "customFieldConfig": {
            "selectValueTypeList": [
              "string",
              "number",
              "boolean",
              "object",
              "arrayString",
              "arrayNumber",
              "arrayBoolean",
              "arrayObject",
              "any",
              "chatHistory",
              "datasetQuote",
              "dynamic",
              "selectApp",
              "selectDataset"
            ],
            "showDescription": false,
            "showDefaultValue": false
          }
        },
        {
          "id": "ozxYHsrGitKE",
          "valueType": "string",
          "type": "dynamic",
          "key": "images[0].url",
          "label": "images[0].url"
        }
      ]
    }
  ],
  "edges": [
    {
      "source": "vFlAtLTLYxl7",
      "target": "e6s2QseLaH23",
      "sourceHandle": "vFlAtLTLYxl7-source-right",
      "targetHandle": "e6s2QseLaH23-target-left"
    },
    {
      "source": "userChatInput",
      "target": "tNbjIPgU4HWr",
      "sourceHandle": "userChatInput-source-right",
      "targetHandle": "tNbjIPgU4HWr-target-left"
    },
    {
      "source": "uHkZxdjD51fW",
      "target": "vFlAtLTLYxl7",
      "sourceHandle": "uHkZxdjD51fW-source-right",
      "targetHandle": "vFlAtLTLYxl7-target-left"
    },
    {
      "source": "aQ5IQRj8Smuo",
      "target": "uHkZxdjD51fW",
      "sourceHandle": "aQ5IQRj8Smuo-source-IF",
      "targetHandle": "uHkZxdjD51fW-target-left"
    },
    {
      "source": "tNbjIPgU4HWr",
      "target": "aQ5IQRj8Smuo",
      "sourceHandle": "tNbjIPgU4HWr-source-right",
      "targetHandle": "aQ5IQRj8Smuo-target-left"
    },
    {
      "source": "sEKrNvlLofIK",
      "target": "xiuk1fLEBlE7",
      "sourceHandle": "sEKrNvlLofIK-source-right",
      "targetHandle": "xiuk1fLEBlE7-target-left"
    },
    {
      "source": "eobfPJ74NcFt",
      "target": "z02LIp9riLnG",
      "sourceHandle": "eobfPJ74NcFt-source-right",
      "targetHandle": "z02LIp9riLnG-target-left"
    },
    {
      "source": "z02LIp9riLnG",
      "target": "sEKrNvlLofIK",
      "sourceHandle": "z02LIp9riLnG-source-right",
      "targetHandle": "sEKrNvlLofIK-target-left"
    },
    {
      "source": "aQ5IQRj8Smuo",
      "target": "eobfPJ74NcFt",
      "sourceHandle": "aQ5IQRj8Smuo-source-ELSE",
      "targetHandle": "eobfPJ74NcFt-target-left"
    }
  ],
  "chatConfig": {
    "welcomeText": "您好,我是FLUX.1 AI绘画小助手.\n\n直接输入提示词(中英文均可)即可使用AI绘画。AI自动优化提示词\n\n[AI 绘画新标杆!一文详解最新开源模型 Flux.1](https://www.uisdc.com/flux-1)",
    "variables": [
      {
        "id": "jvedwl",
        "key": "否",
        "label": "是否启用图生图功能?",
        "type": "select",
        "required": true,
        "maxLen": 50,
        "enums": [
          {
            "value": "是"
          },
          {
            "value": "否"
          }
        ]
      },
      {
        "id": "8a2uxo",
        "key": "1024",
        "label": "图片链接",
        "type": "input",
        "required": false,
        "maxLen": 100,
        "enums": [
          {
            "value": "https://img.zcool.cn/community/01fa8f5aefb92da801206abab0777f.jpg@1280w_1l_2o_100sh.jpg"
          }
        ],
        "icon": "core/app/variable/select"
      },
      {
        "id": "wond9q",
        "key": "1024x1024",
        "label": "选择图像尺寸",
        "type": "select",
        "required": true,
        "maxLen": 50,
        "enums": [
          {
            "value": "1024x1024"
          },
          {
            "value": "576x1024"
          },
          {
            "value": "1024x576"
          }
        ]
      }
    ],
    "whisperConfig": {
      "open": true,
      "autoSend": false,
      "autoTTSResponse": false
    },
    "scheduledTriggerConfig": {
      "cronString": "",
      "timezone": "Asia/Shanghai",
      "defaultPrompt": ""
    },
    "fileSelectConfig": {
      "canSelectFile": true,
      "canSelectImg": true,
      "maxFiles": 10
    },
    "_id": "66c4a5e9501b65de6749f604"
  }
}

Cloudflare 大善人的worker搭建 img to base64

创建worker,编辑代码如下:

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  // 仅允许 POST 请求
  if (request.method !== 'POST') {
    return new Response('Only POST requests are allowed', {
      status: 405,
    })
  }

  // 获取请求中的 JSON 数据
  let json
  try {
    json = await request.json()
  } catch (err) {
    return new Response('Invalid JSON', {
      status: 400,
    })
  }

  // 获取图片链接
  const imageUrl = json.url
  if (!imageUrl) {
    return new Response('URL is required', {
      status: 400,
    })
  }

  try {
    // 从图片链接获取图片数据
    const imageResponse = await fetch(imageUrl)
    if (!imageResponse.ok) {
      return new Response('Failed to fetch image', {
        status: 400,
      })
    }
    
    // 获取图片的二进制数据
    const imageData = await imageResponse.arrayBuffer()

    // 获取图片的 MIME 类型
    const contentType = imageResponse.headers.get('Content-Type') || 'image/webp'

    // 将二进制数据转换为 Base64 编码
    const base64Image = arrayBufferToBase64(imageData)

    // 构建 data URL 格式
    const dataUrl = `data:${contentType};base64,${base64Image}`

    // 返回 Base64 编码的图片数据
    return new Response(JSON.stringify({ dataUrl: dataUrl }), {
      headers: { 'Content-Type': 'application/json' },
    })

  } catch (err) {
    return new Response('Error processing image', {
      status: 500,
    })
  }
}

// 将 ArrayBuffer 转换为 Base64 编码
function arrayBufferToBase64(buffer) {
  let binary = ''
  const bytes = new Uint8Array(buffer)
  const len = bytes.byteLength
  for (let i = 0; i < len; i++) {
    binary += String.fromCharCode(bytes[i])
  }
  return btoa(binary)
}

配置:


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

接入NEW API:

参考: 一分钱不花! 搭建AI自动优化生成提示词 后调用FLUX.1或者SD3 AI绘画,并可接入NEW API,模型工具全免费,永久有效 - 常规话题 / 人工智能 - LINUX DO
接入使用的话,工作流需要稍作修改,把网页分享才能用的功能换成固定的值,图片链接也可由AI取出图片用户话中的链接,然后赋值给图片链接,B站有教程,挺简单的,之后有时间再做AI取出用户话中的图片链接部分的教程。

大功告成

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

252 个赞

wow!前排前排,我来试试

4 个赞

前排,感谢分享

3 个赞

牛哇牛蛙 :+1:

4 个赞

感谢分享这个方法

3 个赞

好教程!顶! :+1: :+1: :+1:

7 个赞

我顶! :+1: :+1: :+1:

1 个赞

感谢大佬分享,请求的话是openai chat格式吧?还是openai image格式

4 个赞

好像是chat格式

26 个赞

我做的工作就是为了转成chat格式 从而接入NEW API

3 个赞

谢谢谢佬佬佬

2 个赞

看了下节点,想知道图片链接转完base64 后,怎么转的提示词。demo 站试过了,图生图还是很准的。
正在研究这块的内容,佬友有空回复我下。

1 个赞

我知道了,图生图没有走文生图的路子,而是直接调用图生图接口。

1 个赞

From 人工智能 to 资源荟萃

#精华神帖添加

图生图,base64出错,{
“error”: {
“message”: “Request failed with status code 400”,
“data”: “URL is required”,
“name”: “AxiosError”,
“method”: “post”,
“code”: “ERR_BAD_REQUEST”
}
}

10 个赞

{
“url”: “”
}

3 个赞

URL is required

3 个赞

感谢分享,我搭建好后,接入oneapi,使用的openai的格式,接入lobechat后,发现无法生成图

完整的回复是(无法生成图片链接):

Here's a detailed prompt for the scene you described:

(mother holding child), loving embrace, tender moment, (maternal bond), (baby:1.2), soft lighting, domestic setting, warm colors, gentle expression, nurturing pose, (detailed faces:1.3), comfortable clothing, living room background, family portrait, emotional connection, masterpiece, best quality, illustration style, depth of field, detailed character study, intimate atmosphere

![ai]({{url}})

图生图的工作流需要稍作修改后才能接入NEW API或者其他第三方网站