FastGPT系列教程:
【1】一分钱不花! 搭建AI自动优化生成提示词或者翻译后 调用FLUX.1或者SD3 AI绘画,并可接入NEW API,模型工具全免费,永久免费 - 资源荟萃 - LINUX DO
【2】一分钱不花! AI图生图,AI优化生成提示词,并可接入NEW API,模型工具全免费,硅基流动 - 资源荟萃 - LINUX DO
起因
发现B站上的Dify教程都是使用自定义插件的方式来使用硅基流动绘画,不仅麻烦而且回答更耗时,而且还需要使用参数提取器AI提取图片链接,一次绘画要调用多次AI,存在回复慢以及不必要的AI调用的问题。
有更简单的方法,所以分享一下。
本次使用到的工具:
介绍:
Dify 提供了多种功能,包括可视化编排、Prompt 编写与调试、数据集管理等,这些功能通过可声明式的 YAML 文件定义 AI 应用的各个方面,如 Prompt、上下文和插件等。此外,Dify 还支持多种类型的 AI 应用,例如聊天助手和知识库,并且可以通过 API 或独立页面形式使用。
Dify 相比FastGPT支持更多种 AI 模型,绝大部分模型都支持,并且还可以看到通过API请求的消息记录。限制更少,使用自用模型同样是不收费的。
AFF 硅基流动 含aff 拉新双方可领取2000万token,可以调用deepseek chat,并且可以永久免费调用FLUX.1模型绘画。FLUX.1应该是目前最强绘画模型。
AI 绘画新标杆!一文详解最新开源模型 Flux.1
【硅基流动文生图规则】
一、分级限速。
二、FLUX.1[dev]模型将于2024年9月23日起开始计费,价格为¥0.006/Mpx/Step。FLUX.1[schnell]模型将继续免费提供。Pro版本收费与dev一致。
FLUX.1[schnell] 免费版IPM为2,Pro版本暂不限制IPM,预计今后会限制IPM为10(用量等级0为例)
Dify生成提示词使用的模型可用硅基流动的一些免费或收费模型,或者使用谷歌Gemini免费模型和Grop的免费llama3.1-70b模型(还可以免去请求grop模型时所需的代理梯子)
效果展示(提示词可隐藏):
工作流非常简单,小白可以看看:
部署教程:
先在 AFF 硅基流动 含aff 中注册,生成api key,复制备用。
来到Dify,右上角打开设置增添硅基流动的API key,之后就可以直接使用相关模型了。
接着来到Dify中按下图顺序依次点击并点击创建
然后,点击头像,点击导入DSL导入我的DSL
我的DSL内容如下,得自己创建一个后缀为.yml的文件,编辑后缀为.yml的文件,复制粘贴我的DSL内容即可,之后再导入文件到Dify:
app:
description: ''
icon: space_invader
icon_background: '#E4FBCC'
mode: advanced-chat
name: FLUX绘画机器人
use_icon_as_answer_icon: true
kind: app
version: 0.1.2
workflow:
conversation_variables: []
environment_variables:
- description: ''
id: 2de03b14-93eb-423a-8ee9-5275b88af911
name: apikey
value: sk-dxjmxkrxxrwscmbprwmrjpjthysujurbyrathhckxgcqgxxu
value_type: string
features:
file_upload:
image:
enabled: false
number_limits: 3
transfer_methods:
- local_file
- remote_url
opening_statement: '搭建教程:https://linux.do/t/topic/215148
[硅基流动 含aff 拉新双方可领取2000万token](https://cloud.siliconflow.cn/i/OzJQNldT)'
retriever_resource:
enabled: false
sensitive_word_avoidance:
enabled: false
speech_to_text:
enabled: false
suggested_questions: []
suggested_questions_after_answer:
enabled: false
text_to_speech:
enabled: false
language: ''
voice: ''
graph:
edges:
- data:
isInIteration: false
sourceType: start
targetType: llm
id: 1711528914102-source-1711528917469-target
source: '1711528914102'
sourceHandle: source
target: '1711528917469'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: llm
targetType: code
id: 1711528917469-source-1727158200027-target
source: '1711528917469'
sourceHandle: source
target: '1727158200027'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: answer
id: 1727158200027-source-1711528919501-target
source: '1727158200027'
sourceHandle: source
target: '1711528919501'
targetHandle: target
type: custom
zIndex: 0
nodes:
- data:
desc: ''
selected: false
title: 开始
type: start
variables: []
height: 54
id: '1711528914102'
position:
x: 86.08781703972625
y: 267.7950935739721
positionAbsolute:
x: 86.08781703972625
y: 267.7950935739721
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
context:
enabled: false
variable_selector: []
desc: ''
memory:
query_prompt_template: '{{#sys.query#}}'
role_prefix:
assistant: ''
user: ''
window:
enabled: true
size: 2
model:
completion_params:
frequency_penalty: 0
max_tokens: 512
presence_penalty: 0
temperature: 0.7
top_p: 1
mode: chat
name: deepseek-ai/DeepSeek-V2-Chat
provider: siliconflow
prompt_template:
- id: e9f65536-0e93-461a-9296-f3c3e1912ed9
role: system
text: "你是一个基于Flux.1模型的提示词生成机器人。根据用户的需求,自动生成符合Flux.1格式的绘画提示词。虽然你可以参考提供的模板来学习提示词结构和规律,但你必须具备灵活性来应对各种不同需求。最终输出应仅限提示词,无需任何其他解释或信息。你的回答必须全部使用英语进行回复我!\n\
\n### **提示词生成逻辑**:\n\n1. **需求解析**:从用户的描述中提取关键信息,包括:\n - 角色:外貌、动作、表情等。\n\
\ - 场景:环境、光线、天气等。\n - 风格:艺术风格、情感氛围、配色等。\n - 其他元素:特定物品、背景或特效。\n\n\
2. **提示词结构规律**:\n - **简洁、精确且具象**:提示词需要简单、清晰地描述核心对象,并包含足够细节以引导生成出符合需求的图像。\n\
\ - **灵活多样**:参考下列模板和已有示例,但需根据具体需求生成多样化的提示词,避免固定化或过于依赖模板。\n - **符合Flux.1风格的描述**:提示词必须遵循Flux.1的要求,尽量包含艺术风格、视觉效果、情感氛围的描述,使用与Flux.1模型生成相符的关键词和描述模式。\n\
\n3. **仅供你参考和学习的几种场景提示词**(你需要学习并灵活调整,\"[ ]\"中内容视用户问题而定):\n - **角色表情集**:\n\
场景说明:适合动画或漫画创作者为角色设计多样的表情。这些提示词可以生成展示同一角色在不同情绪下的表情集,涵盖快乐、悲伤、愤怒等多种情感。\n\
\n提示词:An anime [SUBJECT], animated expression reference sheet, character\
\ design, reference sheet, turnaround, lofi style, soft colors, gentle\
\ natural linework, key art, range of emotions, happy sad mad scared nervous\
\ embarrassed confused neutral, hand drawn, award winning anime, fully\
\ clothed\n\n[SUBJECT] character, animation expression reference sheet\
\ with several good animation expressions featuring the same character\
\ in each one, showing different faces from the same person in a grid\
\ pattern: happy sad mad scared nervous embarrassed confused neutral,\
\ super minimalist cartoon style flat muted kawaii pastel color palette,\
\ soft dreamy backgrounds, cute round character designs, minimalist facial\
\ features, retro-futuristic elements, kawaii style, space themes, gentle\
\ line work, slightly muted tones, simple geometric shapes, subtle gradients,\
\ oversized clothing on characters, whimsical, soft puffy art, pastels,\
\ watercolor\n\n - **全角度角色视图**:\n场景说明:当需要从现有角色设计中生成不同角度的全身图时,如正面、侧面和背面,适用于角色设计细化或动画建模。\n\
\n提示词:A character sheet of [SUBJECT] in different poses and angles, including\
\ front view, side view, and back view\n\n - **80 年代复古风格**:\n场景说明:适合希望创造\
\ 80 年代复古风格照片效果的艺术家或设计师。这些提示词可以生成带有怀旧感的模糊宝丽来风格照片。\n\n提示词:blurry polaroid\
\ of [a simple description of the scene], 1980s.\n\n - **智能手机内部展示**:\n\
场景说明:适合需要展示智能手机等产品设计的科技博客作者或产品设计师。这些提示词帮助生成展示手机外观和屏幕内容的图像。\n\n提示词:a iphone\
\ product image showing the iphone standing and inside the screen the\
\ image is shown\n\n - **双重曝光效果**:\n场景说明:适合摄影师或视觉艺术家通过双重曝光技术创造深度和情感表达的艺术作品。\n\
\n提示词:[Abstract style waterfalls, wildlife] inside the silhouette of a\
\ [man]’s head that is a double exposure photograph . Non-representational,\
\ colors and shapes, expression of feelings, imaginative, highly detailed\n\
\n - **高质感电影海报**:\n场景说明:适合需要为电影创建引人注目海报的电影宣传或平面设计师。\n\n提示词:A digital\
\ illustration of a movie poster titled [‘Sad Sax: Fury Toad’], [Mad Max]\
\ parody poster, featuring [a saxophone-playing toad in a post-apocalyptic\
\ desert, with a customized car made of musical instruments], in the background,\
\ [a wasteland with other musical vehicle chases], movie title in [a gritty,\
\ bold font, dusty and intense color palette].\n\n - **镜面自拍效果**:\n场景说明:适合想要捕捉日常生活瞬间的摄影师或社交媒体用户。\n\
\n提示词:Phone photo: A woman stands in front of a mirror, capturing a selfie.\
\ The image quality is grainy, with a slight blur softening the details.\
\ The lighting is dim, casting shadows that obscure her features. [The\
\ room is cluttered, with clothes strewn across the bed and an unmade\
\ blanket. Her expression is casual, full of concentration], while the\
\ old iPhone struggles to focus, giving the photo an authentic, unpolished\
\ feel. The mirror shows smudges and fingerprints, adding to the raw,\
\ everyday atmosphere of the scene.\n\n - **像素艺术创作**:\n场景说明:适合像素艺术爱好者或复古游戏开发者创造或复刻经典像素风格图像。\n\
\n提示词:[Anything you want] pixel art style, pixels, pixel art\n\n - **以上部分场景仅供你学习,一定要学会灵活变通,以适应任何绘画需求**:\n\
\n4. **Flux.1提示词要点总结**:\n - **简洁精准的主体描述**:明确图像中核心对象的身份或场景。\n - **风格和情感氛围的具体描述**:确保提示词包含艺术风格、光线、配色、以及图像的氛围等信息。\n\
\ - **动态与细节的补充**:提示词可包括场景中的动作、情绪、或光影效果等重要细节。\n - **其他更多规律请自己寻找**\n\
---\n\n**问答案例**:\n**用户输入**:一个80年代复古风格的照片。\n**你的输出**:`A blurry polaroid\
\ of a 1980s living room, with vintage furniture, soft pastel tones, and\
\ a nostalgic, grainy texture, The sunlight filters through old curtains,\
\ casting long, warm shadows on the wooden floor, 1980s,`\n\n注意:你的生成内容绝对不允许含有“![ai](任意链接)”。哪怕你之前不小心含有“![ai](任意链接)”内容,请在下一次绝对不允许含有“![ai](任意链接)”内容。\n\
\n\n"
- id: 0a665329-56bf-4389-9a8d-995bc0f73e15
role: user
text: 一个赛博朋克风格的夜晚城市背景
- id: 17ed80b3-a482-4d8b-b594-c6df54f34c3c
role: assistant
text: A futuristic cityscape at night, in a cyberpunk style, with neon lights
reflecting off wet streets, towering skyscrapers, and a glowing, high-tech
atmosphere. Dark shadows contrast with vibrant neon signs, creating a
dramatic, dystopian mood
selected: true
title: 生成提示词
type: llm
variables: []
vision:
enabled: false
height: 98
id: '1711528917469'
position:
x: 335.49205862738665
y: 267.7950935739721
positionAbsolute:
x: 335.49205862738665
y: 267.7950935739721
selected: true
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
answer: '{{#1711528917469.text#}}
{{#1727158200027.result#}}
'
desc: ''
selected: false
title: 绘画结果
type: answer
variables: []
height: 126
id: '1711528919501'
position:
x: 833.237352833331
y: 267.7950935739721
positionAbsolute:
x: 833.237352833331
y: 267.7950935739721
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
code: "import requests\nimport json\n\n\ndef main(prompt: str, apikey: str)\
\ -> dict:\n # 设置请求的URL和Headers\n url = \"https://api.siliconflow.cn/v1/image/generations\"\
\n headers = {\n \"accept\": \"application/json\",\n \"\
authorization\": f\"Bearer {apikey}\",\n \"content-type\": \"application/json\"\
\n }\n\n # 定义请求的payload数据\n data = {\n \"model\": \"black-forest-labs/FLUX.1-schnell\"\
,\n \"prompt\": prompt,\n \"image_size\": \"1024x1024\"\n\
\ }\n\n # 发送POST请求\n response = requests.post(url, headers=headers,\
\ data=json.dumps(data))\n\n # 提取结果并返回\n if response.status_code ==\
\ 200:\n result = response.json()[\"images\"][0][\"url\"]\n \
\ markdown_result = f\"![ai]({result})\"\n return {\"result\":\
\ markdown_result}\n else:\n return {\"error\": f\"Error: {response.status_code},\
\ {response.text}\"}\n"
code_language: python3
desc: ''
outputs:
result:
children: null
type: string
selected: false
title: FLUX1绘画
type: code
variables:
- value_selector:
- '1711528917469'
- text
variable: prompt
- value_selector:
- env
- apikey
variable: apikey
height: 54
id: '1727158200027'
position:
x: 584.5675907110967
y: 267.7950935739721
positionAbsolute:
x: 584.5675907110967
y: 267.7950935739721
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
viewport:
x: -66.1772849602844
y: -0.8878536352083302
zoom: 1.478362431273845
之后会看到如下界面,按下图顺序点击,并设置名称为“apikey”,值为“硅基流动的API key”,用于调用FLUX.1。
点击发布并带点击下方的“运行”即可在网页中使用。
大功告成
这是我搭建的,大家可以免费试试:Dify