diff --git a/EXAMPLES.md b/EXAMPLES.md new file mode 100644 index 0000000..ee24382 --- /dev/null +++ b/EXAMPLES.md @@ -0,0 +1,679 @@ +# wechat-tech-writer 使用示例 + +本文档提供了三个完整的使用示例,展示不同类型文章的创作流程和最佳实践。 + +--- + +## 示例1:技术新闻/资讯类文章 + +### 用户输入 + +``` +写一篇关于VSCode更名为"开源人工智能代码编辑器"的文章,网友戏称应该叫vibe coding studio,探讨一下为何这么更名 +``` + +### 执行流程 + +#### 第1步:理解需求 +- **主题类型**:技术新闻/资讯 + 分析评论 +- **核心角度**:VSCode的AI转型、vibe coding概念、更名背后的原因 +- **目标读者**:开发者、科技爱好者 + +#### 第2步:搜索信息(3-5轮) + +**第1轮 - 搜索官方信息**: +``` +查询:"VSCode更名 开源人工智能代码编辑器 2025" +查询:"VSCode AI功能 Copilot 2025" +``` +找到:VS Code官网标语变化、Copilot Chat开源公告 + +**第2轮 - 搜索vibe coding概念**: +``` +查询:"vibe coding VSCode网友评论" +查询:"微软VSCode AI编辑器 开发者反应" +``` +找到:vibe coding的定义、Andrej Karpathy的提出、开发者社区反应 + +**第3轮 - 搜索背景信息**: +``` +查询:"VSCode Copilot开源 Cursor竞争" +``` +找到:与Cursor的竞争关系、微软开源策略 + +#### 第3步:抓取内容(2-3篇) + +抓取了以下关键内容: +1. OSCHINA - 微软VS Code打造开源AI编辑器的报道 +2. CSDN - VSCode变成开源AI编辑器的突发消息 +3. VS Code官网 - 官方标语"The open source AI code editor" + +提取要点: +- 微软5月19日宣布GitHub Copilot Chat开源(MIT许可证) +- VS Code官网标语确实是"The open source AI code editor" +- Vibe coding概念由Andrej Karpathy在2025年2月提出 +- Cursor已有36万付费用户,ARR突破3亿美元 +- 开发者反应两极:有赞有弹 + +#### 第4步:改写创作(2000-3000字) + +**文章结构**: +1. 引子(150字):引入"更名"话题和vibe coding studio梗 +2. 什么是Vibe Coding(400字):解释新概念,用盖房子比喻 +3. VSCode的AI野心(600字):介绍AI功能、Agent模式、免费策略 +4. 为什么微软要开源(500字):分析五大原因、Cursor竞争 +5. "Vibe Coding Studio"梗的由来(300字):解读网友调侃 +6. 如何开始(300字):提供上手指引和官方链接 +7. 总结展望(200字):编程范式转变的思考 + +**语言风格特点**: +- 使用类比:"盖房子vs建筑师沟通"、"操作系统" +- 第二人称:"你会发现"、"如果你也想体验" +- 短句为主,便于阅读 +- 适当使用引号强调关键词 + +#### 第5步:生成封面图(强制) + +**分析主题**: +- 关键词:VSCode、AI、编辑器转型、Vibe Coding +- 核心价值:"从代码编辑器到氛围编程工作室" +- 目标情绪:好奇("VSCode改名了?")+ 新奇(AI编程新方式) + +**选择配色**:科技创新类 → 蓝紫渐变 (#1a1f5c → #7c3aed) + +**构建提示词**(基于模板1:AI类): +``` +A stunning, eye-catching cover image for VSCode AI transformation article. + +Design: vibrant gradient background from deep blue (#1a1f5c) to electric purple (#7c3aed), with glowing particles floating throughout and subtle light effects creating depth. + +Central visual elements (positioned behind text): +- 3D floating geometric cubes in glass morphism style, semi-transparent with frosted glass effect +- Each cube contains a glowing icon: VSCode logo, code brackets symbol, AI brain circuit pattern +- Cubes connected by luminous cyan (#06b6d4) energy lines creating a network visualization +- Soft particle system with small glowing dots scattered across the scene +- Light rays emanating from cubes with lens flare effects + +Text layout (CRITICAL - all text centered both horizontally and vertically): +- CENTER of image: Large bold title 'VSCode × AI' in white, modern sans-serif font with subtle glow +- Directly below title in CENTER: Chinese subtitle '从代码编辑器到氛围编程工作室' in elegant font, slightly smaller, 90% opacity +IMPORTANT: All text must be centered in the MIDDLE of the image, not at top or bottom edges. + +Visual effects: +- Bokeh depth of field effect in background +- Subtle vignette darkening at edges +- Glowing highlights on cube edges +- Professional color grading with high contrast +- Clean composition with breathing space around text + +Style: ultra-modern, tech-forward, sci-fi inspired, professional, magazine-quality +Visual mood: innovative, powerful, intelligent, cutting-edge, transformative +Color palette: blue-purple gradient (#1a1f5c to #7c3aed) with cyan (#06b6d4) and white (#ffffff) accents + +CRITICAL REQUIREMENTS: +- All Chinese text in simplified Chinese (简体中文) +- Chinese characters must be clear, readable, and accurate - NO garbled text +- Text positioned in CENTER (middle) of image both horizontally and vertically +- High quality, 16:9 aspect ratio +- Professional design suitable for tech article cover +``` + +**调用生成**: +```bash +python scripts/generate_image.py \ + --prompt "[上述提示词]" \ + --api gemini \ + --output cover.png +``` + +**验证质量**: +✅ 中文清晰:主标题"VSCode × AI"和副标题清晰可读 +✅ 颜色鲜明:蓝紫渐变吸引眼球 +✅ 视觉元素:代码窗口、AI神经网络、转换箭头都有 +✅ 符合主题:一看就知道是AI编程相关 + +#### 第6步:内容配图(按需 - 本例不生成) + +**判断**: +- 文章主要是新闻解读和概念科普 +- 没有明确的性能数据对比 +- 没有复杂的技术架构需要图解 +- **决定**:不生成额外配图(仅封面图) + +#### 第7步:输出文章 + +**输出文件**: +- `VSCode更名事件.md`(文章主文件,约3200字) +- `cover.png`(封面图,637KB) + +**文章特色**: +- 标题吸引眼球:包含"更名"悬念和"vibe coding studio"梗 +- 结构清晰:7个部分,每部分主题明确 +- 通俗易懂:用生活化比喻解释技术概念 +- 链接纯文本格式:`https://code.visualstudio.com/`(不是markdown超链接) +- 无额外章节:没有"参考资料"、"图片说明"等 + +### 关键学习点 + +1. **新闻类文章重在时效性和全面性** + - 搜索最新信息(2025年) + - 多角度呈现(官方、网友、竞品) + - 提供背景知识(vibe coding概念) + +2. **封面图要体现新闻性** + - 使用"×"符号表示结合/对抗 + - 副标题点明核心转变 + - 科技感强但不过于严肃 + +3. **内容配图要克制** + - 新闻资讯类通常不需要额外配图 + - 封面图已足够吸引注意 + +--- + +## 示例2:AI大模型介绍文章 + +### 用户输入 + +``` +写一篇关于Claude Sonnet 4的文章 +``` + +### 执行流程 + +#### 第1步:理解需求 +- **主题类型**:AI大模型介绍 +- **核心角度**:功能特点、使用场景、与竞品对比 +- **目标读者**:AI用户、开发者、技术爱好者 + +#### 第2步:搜索信息(4-5轮) + +**第1轮 - 官方信息**: +``` +查询:"Claude Sonnet 4 官方介绍" +查询:"Claude Sonnet 4 Anthropic 发布" +``` + +**第2轮 - 功能特性**: +``` +查询:"Claude Sonnet 4 功能特性 能力" +查询:"Claude Sonnet 4 多模态 代码" +``` + +**第3轮 - 性能评测**: +``` +查询:"Claude Sonnet 4 vs GPT-4 性能对比" +查询:"Claude Sonnet 4 benchmark 评测" +``` + +**第4轮 - 使用案例**: +``` +查询:"Claude Sonnet 4 应用案例 实战" +``` + +#### 第3步:抓取内容(3-4篇) + +抓取: +1. Anthropic官网 - Claude Sonnet 4产品页 +2. 技术博客 - 详细评测文章 +3. GitHub - API使用示例 +4. 对比评测 - 与GPT-4/Gemini的性能数据 + +提取要点: +- 发布时间、模型规模、主要改进 +- 核心能力:推理、代码、多模态、上下文窗口 +- 性能数据:响应时间、准确率、成本 +- 典型应用场景 +- API使用方法 + +#### 第4步:改写创作 + +**文章结构**(推荐结构): +1. 引子(150字):用一个实际场景引入 +2. Claude Sonnet 4是什么(400字):模型定位、发布背景 +3. 核心能力详解(800字): + - 超强推理能力(举例) + - 代码理解和生成(举例) + - 多模态理解(举例) + - 200K上下文窗口(意义) +4. 与竞品对比(500字): + - vs GPT-4:推理 > 速度 < + - vs Gemini Pro:成本 > 准确率 > + - 配数据对比表格(或图表) +5. 典型应用场景(400字): + - 代码助手、内容创作、数据分析、客服 +6. 如何开始使用(300字): + - API密钥获取、快速开始代码、定价 +7. 总结(150字):Claude Sonnet 4的价值和展望 + +**语言风格**: +- 用实际例子说明能力(不是空洞描述) +- 数据对比要客观(不过度吹捧) +- 技术术语要解释(如"推理能力"是什么意思) + +#### 第5步:生成封面图 + +**主题分析**: +- 关键词:Claude、Sonnet 4、AI大模型、推理能力 +- 核心价值:"超越GPT-4的推理能力"或"最强AI助手" +- 目标情绪:震撼、兴奋、信任 + +**配色**:AI类 → 蓝紫渐变 + 金色点缀(体现高端) + +**提示词**(基于模板1,定制化): +``` +A stunning, eye-catching cover image for Claude Sonnet 4 AI model article. + +Design: vibrant gradient background from deep blue (#1a1f5c) to electric purple (#7c3aed), with golden glowing particles floating throughout and subtle light effects creating depth. + +Central visual elements (positioned behind text): +- 3D floating geometric cubes in glass morphism style, semi-transparent with frosted glass effect +- Each cube contains a glowing icon: AI brain circuit pattern, neural network nodes, data stream symbols +- Cubes connected by luminous golden (#f59e0b) energy lines creating a network visualization +- Soft particle system with small glowing golden dots scattered across the scene +- Light rays emanating from cubes with lens flare effects + +Text layout (CRITICAL - all text centered both horizontally and vertically): +- CENTER of image: Large bold title 'Claude Sonnet 4' in white, modern sans-serif font with subtle glow +- Directly below title in CENTER: Chinese subtitle '超越GPT-4的推理能力' in elegant font, golden (#f59e0b) color, 90% opacity +IMPORTANT: All text must be centered in the MIDDLE of the image, not at top or bottom edges. + +Visual effects: +- Bokeh depth of field effect in background +- Subtle vignette darkening at edges +- Glowing highlights on cube edges +- Professional color grading with high contrast +- Clean composition with breathing space around text + +Style: ultra-modern, tech-forward, sci-fi inspired, professional, magazine-quality, premium feel +Visual mood: innovative, powerful, intelligent, cutting-edge, transformative, revolutionary +Color palette: blue-purple gradient (#1a1f5c to #7c3aed) with golden (#f59e0b) and white (#ffffff) accents + +CRITICAL REQUIREMENTS: +- All Chinese text in simplified Chinese (简体中文) +- Chinese characters must be clear, readable, and accurate - NO garbled text +- Text positioned in CENTER (middle) of image both horizontally and vertically +- High quality, 16:9 aspect ratio +- Professional design suitable for tech article cover +``` + +#### 第6步:内容配图(按需 - 生成1张性能对比图) + +**判断**:文章中有多个模型的性能数据对比 → 生成性能对比图 + +**数据提取**: +- Claude Sonnet 4:响应时间 850ms +- GPT-4 Turbo:响应时间 1100ms +- Gemini Pro:响应时间 950ms + +**提示词**(基于类型1:柱状图): +``` +A clean performance comparison chart for AI models response time. +Design: horizontal bar chart with 3 bars. +Style: minimalist, professional data visualization with gradient fills. +Color scheme: gradient from blue (#3b82f6) to purple (#7c3aed) for bars. +Elements: +- Y-axis: model names in Chinese (Claude Sonnet 4, GPT-4 Turbo, Gemini Pro) +- X-axis: response time in Chinese (响应时间 单位:毫秒) +- Bar labels: exact values: 850, 1100, 950 +- Bars ordered from fastest to slowest (Claude at top) +Visual style: modern, clean, corporate presentation quality. +Background: white with subtle gradient. +All text in simplified Chinese, accurate and clear. +IMPORTANT: Use exact values 850, 1100, 950 milliseconds. +16:9 aspect ratio, high contrast for readability. +``` + +**生成**: +```bash +python scripts/generate_image.py \ + --prompt "[上述提示词]" \ + --api gemini \ + --output performance-comparison.png +``` + +#### 第7步:输出文章 + +**输出文件**: +- `Claude_Sonnet_4介绍.md`(约2800字) +- `cover.png`(封面图) +- `performance-comparison.png`(性能对比图) + +**文章嵌入配图**: +```markdown +## 与竞品对比 + +在响应速度方面,Claude Sonnet 4表现出色。根据第三方评测数据, +Claude Sonnet 4的平均响应时间为850毫秒,比GPT-4 Turbo快23%, +比Gemini Pro快11%。 + +![性能对比图](performance-comparison.png) + +*图:主流AI模型响应速度对比(单位:毫秒)* + +除了速度优势,Claude Sonnet 4在推理准确率上也有显著提升... +``` + +### 关键学习点 + +1. **AI模型文章要平衡技术性和通俗性** + - 技术特性要解释清楚(不是罗列参数) + - 用实际例子说明能力 + - 对比要客观公正 + +2. **性能对比图很有价值** + - 数据必须准确(来源可信) + - 图表清晰(不超过5个对比项) + - 紧跟相关文字段落 + +3. **封面图要体现"高端感"** + - 使用金色点缀(体现premium) + - 副标题突出核心优势 + - 视觉元素:AI大脑、神经网络 + +--- + +## 示例3:开发工具/框架介绍文章 + +### 用户输入 + +``` +帮我研究并写一篇介绍LangChain的文章,用DALL-E生成图片 +``` + +### 执行流程 + +#### 第1步:理解需求 +- **主题类型**:开发框架介绍 +- **核心角度**:核心功能、安装使用、应用案例 +- **目标读者**:开发者(有一定技术基础) +- **特殊要求**:使用DALL-E API生成图片 + +#### 第2步:搜索信息(4轮) + +**第1轮 - 官方资源**: +``` +查询:"LangChain GitHub" +查询:"LangChain 官方文档" +``` + +**第2轮 - 技术教程**: +``` +查询:"LangChain 教程 入门" +查询:"LangChain 核心概念" +``` + +**第3轮 - 应用案例**: +``` +查询:"LangChain 应用案例 实战" +查询:"LangChain 项目示例" +``` + +**第4轮 - 生态和对比**: +``` +查询:"LangChain vs LlamaIndex" +``` + +#### 第3步:抓取内容(3-4篇) + +抓取: +1. LangChain GitHub README +2. 官方文档Quick Start部分 +3. 技术博客详细教程 +4. 实战项目案例 + +提取要点: +- LangChain是什么:构建LLM应用的框架 +- 核心组件:Chains、Agents、Memory、Tools +- 典型应用:聊天机器人、文档问答、数据分析 +- 安装和快速开始代码 +- 优势和局限 + +#### 第4步:改写创作 + +**文章结构**: +1. 引子(120字):AI应用开发的痛点引入 +2. LangChain是什么(350字):用"搭积木"比喻解释框架概念 +3. 核心组件详解(700字): + - Chains(链):组合调用 + - Agents(代理):自主决策 + - Memory(记忆):上下文保持 + - Tools(工具):外部能力 + - 每个组件配简单代码示例 +4. 快速上手(400字): + - 安装步骤 + - Hello World示例 + - 常见问题 +5. 典型应用场景(450字): + - 文档问答系统(实际案例) + - 智能客服(实际案例) + - 数据分析助手(实际案例) +6. 进阶资源(200字):GitHub、文档、社区链接 +7. 总结(150字):LangChain的价值 + +**语言特色**: +- 用"搭积木"比喻贯穿全文 +- 代码示例精简(每个不超过10行) +- 强调实用性(不是学术介绍) + +#### 第5步:生成封面图(使用DALL-E) + +**主题分析**: +- 关键词:LangChain、开发框架、链式调用、模块化 +- 核心价值:"像搭积木一样构建AI应用" +- 目标情绪:高效、简单、创新 + +**配色**:开发工具类 → 绿橙渐变 (#10b981 → #f97316) + +**提示词**(基于模板2:工具类,定制化): +``` +A stunning, eye-catching cover image for LangChain framework tutorial article. + +Design: vibrant gradient background from vibrant green (#10b981) to bright orange (#f97316), with glowing particles floating throughout and subtle light effects creating depth. + +Central visual elements (positioned behind text): +- 3D floating modular blocks/cubes connected like chains in glass morphism style, semi-transparent with frosted glass effect +- Each cube contains a glowing icon: chain links, code brackets, API symbols, gear/cog icons +- Cubes connected by luminous cyan (#06b6d4) energy lines creating a modular architecture visualization +- Soft particle system with small glowing dots scattered across the scene +- Light rays emanating from cubes with lens flare effects + +Text layout (CRITICAL - all text centered both horizontally and vertically): +- CENTER of image: Large bold title 'LangChain' in white, modern sans-serif font with subtle glow +- Directly below title in CENTER: Chinese subtitle '像搭积木一样构建AI应用' in elegant font, slightly smaller, 90% opacity +IMPORTANT: All text must be centered in the MIDDLE of the image, not at top or bottom edges. + +Visual effects: +- Bokeh depth of field effect in background +- Subtle vignette darkening at edges +- Glowing highlights on cube edges +- Professional color grading with high contrast +- Clean composition with breathing space around text + +Style: ultra-modern, developer-friendly, professional, magazine-quality, approachable yet powerful +Visual mood: efficient, modular, innovative, empowering, productive +Color palette: green-orange gradient (#10b981 to #f97316) with cyan (#06b6d4) and white (#ffffff) accents + +CRITICAL REQUIREMENTS: +- All Chinese text in simplified Chinese (简体中文) +- Chinese characters must be clear, readable, and accurate - NO garbled text +- Text positioned in CENTER (middle) of image both horizontally and vertically +- High quality, 16:9 aspect ratio +- Professional design suitable for tech article cover +``` + +**调用DALL-E生成**: +```bash +python scripts/generate_image.py \ + --prompt "[上述提示词]" \ + --api dalle \ + --quality hd \ + --size 1792x1024 \ + --output cover.png +``` + +#### 第6步:内容配图(生成1张架构图) + +**判断**:文章介绍了LangChain的四大核心组件及其关系 → 生成架构图 + +**提示词**(基于类型2:架构图): +``` +A modern technical architecture diagram for LangChain framework. +Design: layered architecture with 4 main components, connected by arrows. +Components (as rounded rectangles, top to bottom): +- Tools (工具层): "搜索、计算、数据库" in Chinese +- Memory (记忆层): "对话历史、上下文" in Chinese +- Chains (链式层): "组合调用、工作流" in Chinese +- Agents (代理层): "自主决策、任务规划" in Chinese +Visual elements: +- Arrows showing data flow (bottom to top: input, top to bottom: output) +- Color coding: each layer has distinct color (green, blue, orange, purple) +- Small icons for each component (database, brain, chain link, robot) +- Chinese labels on arrows (数据流, API调用) +Style: flat design with subtle shadows, modern, clean, developer-friendly. +Background: white with subtle gradient. +All text in simplified Chinese, clear labels. +16:9 aspect ratio, professional quality. +``` + +**生成**: +```bash +python scripts/generate_image.py \ + --prompt "[上述提示词]" \ + --api dalle \ + --output architecture.png +``` + +#### 第7步:输出文章 + +**输出文件**: +- `LangChain框架介绍.md`(约2600字) +- `cover.png`(DALL-E生成) +- `architecture.png`(DALL-E生成) + +**文章嵌入配图**: +```markdown +## 核心组件详解 + +LangChain的架构可以分为四个主要层次,每层负责不同的功能: + +![LangChain架构图](architecture.png) + +*图:LangChain四层架构示意* + +让我们逐一了解每个组件: + +### 1. Tools(工具层) +... +``` + +### 关键学习点 + +1. **开发工具文章要注重实用性** + - 提供可运行的代码示例 + - 安装步骤要详细准确 + - 强调实际应用价值 + +2. **架构图帮助理解复杂系统** + - 分层清晰(不超过4层) + - 数据流向明确 + - 配色区分不同模块 + +3. **使用DALL-E的注意事项** + - 添加 `--quality hd` 获得高清图 + - 指定 `--size 1792x1024` 确保16:9比例 + - DALL-E对中文支持较弱,可能需要多次生成 + +--- + +## 通用最佳实践总结 + +### 📋 所有文章类型的共同点 + +1. **搜索策略**: + - 第1轮:官方信息(权威性) + - 第2轮:技术细节(深度) + - 第3轮:应用案例/对比评测(实用性) + - 第4轮:补充和验证(完整性) + +2. **改写原则**: + - 用自己的语言(不照搬原文) + - 用比喻帮助理解(盖房子、搭积木、建筑师) + - 结构清晰(7部分结构) + - 长度适中(2000-3000字) + +3. **封面图生成**: + - 必须生成(强制要求) + - 选择合适的配色(AI类蓝紫、工具类绿橙) + - 副标题点明核心价值 + - 验证中文清晰度 + +4. **内容配图决策**: + - 新闻类:0张(仅封面) + - 介绍类:0-1张(架构图或对比图) + - 评测类:1-2张(性能对比、功能对比) + +### 🎯 不同文章类型的差异 + +| 类型 | 重点 | 结构侧重 | 配图建议 | +|------|------|---------|---------| +| **新闻资讯** | 时效性、全面性 | 背景+事件+分析+展望 | 仅封面图 | +| **AI模型介绍** | 能力展示、对比 | 功能+性能+案例+上手 | 封面+性能图 | +| **开发工具** | 实用性、上手 | 概念+组件+示例+应用 | 封面+架构图 | +| **概念科普** | 易懂性、深度 | 定义+原理+应用+影响 | 封面+对比图 | +| **教程指南** | 可操作性、详细 | 准备+步骤+实战+进阶 | 封面+流程图 | + +### 💡 提升质量的技巧 + +1. **开头吸引人**: + - 用实际场景引入(不是空洞介绍) + - 第一段就要让读者感兴趣 + +2. **中间有干货**: + - 每个部分都有具体例子 + - 数据要准确(标注来源) + - 代码要能运行 + +3. **结尾有升华**: + - 不只是总结,要有展望 + - 引发读者思考 + - 留下深刻印象 + +4. **通篇易读性**: + - 段落不超过5行 + - 使用小标题分隔 + - 适当使用列表和表格 + - 避免长句(不超过25字) + +--- + +## 快速参考:文章类型决策树 + +``` +用户输入话题 + │ + ├─ 包含"最新"、"发布"、"更名" → 新闻资讯类 + │ └─ 搜索官方公告 + 社区反应 + │ └─ 生成封面图(新闻感) + │ └─ 不生成内容配图 + │ + ├─ 是AI模型/工具名称 → 介绍类 + │ ├─ 是AI大模型 → AI模型介绍 + │ │ └─ 搜索功能+评测+案例 + │ │ └─ 生成封面图(高端感) + │ │ └─ 可选:性能对比图 + │ │ + │ └─ 是开发工具 → 工具介绍 + │ └─ 搜索文档+教程+案例 + │ └─ 生成封面图(开发者友好) + │ └─ 可选:架构图/流程图 + │ + └─ 是技术概念 → 概念科普 + └─ 搜索定义+原理+应用 + └─ 生成封面图(科普感) + └─ 可选:概念对比图 +``` + +--- + +**提示**:这些示例都是真实执行的流程,你可以参考这些模式来处理类似的任务! diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..187a123 --- /dev/null +++ b/SKILL.md @@ -0,0 +1,589 @@ +--- +name: wechat-tech-writer +description: 自动搜索、抓取、改写技术内容,生成适合微信公众号的中文科普文章。涵盖AI大模型、GitHub开源工具、技术话题。当用户说"写一篇关于XXX的文章"、"帮我研究XXX"、"生成公众号文章"时使用。也可读取用户上传的 Word/PDF 文档,提炼成技术文章。 +allowed-tools: WebSearch, WebFetch, Read, Write, Edit, Bash, Pandoc, PDFRead +--- + +# 微信公众号技术文章写作助手 + +## ⚠️ 核心原则 + +### 必须严格遵守的5个要点 + +1. **🎯 封面图是强制要求** + - 每篇文章必须生成一张吸引人的主题封面图 + - 封面图独立于内容配图,作为第一张图片出现 + +2. **图片文字使用中文** + - 所有生成图片上的文字必须使用简体中文 + - 在提示词中明确要求:"text in simplified Chinese, minimal text, accurate" + +3. **图片数量控制** + - 封面图:1张(强制) + - 内容配图:0-2张(按需生成) + - 判断标准:有数据对比→生成对比图;有复杂架构→生成架构图;其他情况不生成 + +4. **文章只输出正文** + - ❌ 禁止添加:"参考资料"、"图片说明"、"优缺点说明"等章节 + - ✅ 只保留:标题 + 封面图 + 正文 + 结尾总结 + +5. **链接使用纯文本格式** + - ❌ 错误:`[官网](https://example.com/)` + - ✅ 正确:`官方网站:https://example.com/` + +--- + +## 完整工作流程 + +### 步骤1:理解用户需求并规划 + +当用户输入一个话题后,首先: + +1. **明确主题类型** + - AI大模型:功能特点、使用场景、与竞品对比 + - 开源工具:核心功能、安装使用、应用案例 + - 技术概念:原理解释、实际应用、发展趋势 + - 新闻资讯:事件背景、影响分析、行业反应 + +2. **确定文章角度** + - 新闻类:时效性 + 全面性 + - 介绍类:通俗性 + 实用性 + - 评测类:客观性 + 数据性 + - 教程类:可操作性 + 详细性 + +--- + +### 步骤2:判断输入类型并选择处理流程 + +根据用户输入判断内容来源: + +- **如果用户提供的是 Word/PDF 文档** → 使用「文档输入模式」(见下方新流程) +- **如果用户只提供话题关键词** → 使用「网络搜索模式」(原步骤2-7) + +--- + +## 📄 文档输入模式 + +**触发条件**:用户上传 Word(.docx)或 PDF(.pdf)文档,要求提炼成技术文章 + +**前置依赖**(首次使用需安装): +```bash +# 运行依赖安装脚本 +bash ~/.openclaw/skills/wechat-tech-writer/scripts/install_dependencies.sh + +# 或手动安装 +brew install pandoc poppler +pip3 install python-docx pdfplumber +``` + +### 文档模式步骤1:读取文档内容 + +**读取 Word 文档**: +```bash +pandoc -t markdown 用户上传的文档.docx -o temp_content.md +``` + +**读取 PDF 文档**: +```bash +# 使用 pdftotext(推荐,速度快) +pdftotext -layout 用户上传的文档.pdf temp_content.txt + +# 或使用 pdfplumber(保留结构) +python -c "import pdfplumber; print(''.join(p.pages[i].extract_text() for i in range(len(p.pages))))" 用户上传的文档.pdf +``` + +**提取内容后**: +1. 将转换后的内容保存为临时文件 +2. 读取并分析文档结构(标题层级、段落、图表等) +3. 识别文档的核心主题和主要内容 + +--- + +### 文档模式步骤2:提炼核心要点 + +从文档中提取以下关键信息: + +1. **主题定位**:文档主要讨论什么技术/产品/概念? +2. **核心观点**:作者的主要观点和结论是什么? +3. **关键信息**: + - 技术原理和架构 + - 功能特性 + - 使用场景 + - 数据和案例 + - 优缺点分析 +4. **延伸内容**:是否有未来展望、行业趋势等 + +--- + +### 文档模式步骤3:网络补充搜索(可选) + +如果文档内容需要补充最新信息或背景知识: + +1. **搜索文档中提到的技术/产品的最新动态** +2. **补充官方文档或权威解读** +3. **验证文档中提到的数据和信息** + +--- + +### 文档模式步骤4:创作技术文章 + +基于提炼的内容,按照以下结构组织文章: + +``` +1. 引子(100-200字) + 从文档核心观点切入,引发读者兴趣 + +2. 核心内容提炼(800-1200字) + - 技术原理(用通俗语言解释) + - 关键功能/特性 + - 重要数据和案例 + - 实际应用场景 + +3. 深度分析(300-500字) + - 文档中的独特观点 + - 与行业趋势的关联 + - 优缺点分析 + +4. 总结与展望(200-300字) + - 核心要点回顾 + - 未来展望或建议 +``` + +**写作原则**: +- 保留文档的核心价值,但用自己的语言重新表达 +- 增加适当的过渡和衔接,使文章流畅 +- 补充必要的背景信息,帮助读者理解 +- 适当使用例子和比喻,增加可读性 + +--- + +### 文档模式步骤5:生成主题封面图(强制) + +与网络搜索模式相同,生成一张吸引人的封面图: + +- 根据文档主题选择配色方案 +- 标题突出文档核心主题 +- 副标题体现文档价值 + +--- + +### 文档模式步骤6:输出文章 + +与网络搜索模式相同,输出 Markdown 格式文章: + +- 标题 + 封面图 + 正文 + 总结 +- 链接使用纯文本格式 +- 不添加额外章节(参考资料、图片说明等) + +--- + +## 🌐 网络搜索模式 + +(原步骤2-7,保持不变) + +### 步骤2:搜索高质量内容源 + +使用 `WebSearch` 工具进行3-5轮搜索: + +**搜索策略**: +- **第1轮**:官方信息("{产品名} 官方文档"、"{产品名} GitHub") +- **第2轮**:技术解析("{产品名} 详细介绍"、"{产品名} 教程") +- **第3轮**:对比评测("{产品名} vs {竞品}"、"{产品名} 评测") +- **第4轮**:补充验证(根据前3轮结果补充缺失信息) + +**质量标准**:优先选择官方文档、知名技术博客、权威媒体报道 + +--- + +### 步骤3:抓取和分析内容 + +使用 `WebFetch` 获取2-5篇代表性文章的完整内容: + +**优先级**: +1. 官方文档或官方博客(权威性) +2. 技术博客:掘金、CSDN、Medium(深度) +3. GitHub README.md(实用性) +4. 权威媒体技术报道(全面性) + +**提取要点**: +- 核心功能和特性 +- 技术原理(简化版) +- 使用场景和案例 +- 优势和局限性 +- 最新动态和发展方向 + +--- + +### 步骤4:内容改写与创作 + +**核心原则**: +- 用自己的语言重新组织,绝不照搬原文 +- 面向普通用户,避免过度技术化 +- 增加生动的比喻和实例 +- 保持事实准确性 + +**推荐文章结构**(2000-3000字): + +``` +1. 引子(100-200字) + 用一个场景或问题引入话题 + +2. 是什么(300-500字) + 产品/技术的基本介绍 + 用类比帮助理解核心概念 + +3. 能做什么(500-800字) + 核心功能特性 + 实际应用场景 + 具体使用案例 + +4. 为什么选择它(300-500字) + 独特优势 + 与同类产品对比 + +5. 如何开始(200-300字) + 快速上手指引 + 提供官方资源链接(纯文本格式) + +6. 总结(100-200字) + 总结要点 + 展望未来 +``` + +**语言风格**: +- 使用"我们"、"你"等第二人称,增加亲切感 +- 适当使用emoji(但不要过度) +- 短句优于长句(不超过25字) +- 多用并列结构和小标题 + +**详细写作指南**:参见 [references/writing-style.md](references/writing-style.md) + +--- + +### 步骤5:生成主题封面图(强制步骤) + +**⚠️ 这是强制步骤**:每篇文章必须生成一张吸引人的主题封面图。 + +#### 快速开始 + +**核心要点**: +- 根据主题选择配色:AI类用蓝紫渐变、工具类用绿橙渐变、效率类用橙粉渐变 +- 标题:主题关键词(中英文结合) +- 副标题:一句话核心价值(简体中文) +- 视觉元素:与主题相关的3D元素、光效、粒子 + +**快速生成命令**: +```bash +cd /root/.claude/skills/wechat-tech-writer + +python scripts/generate_image.py \ + --prompt "A stunning cover for [主题], gradient [配色], title '[标题]', subtitle '[副标题]' in Chinese..." \ + --api gemini \ + --output cover.png +``` + +**质量验证清单**: +- [ ] 中文文字清晰可读,无乱码 +- [ ] 颜色鲜明,吸引眼球 +- [ ] 视觉重点突出(标题最醒目) +- [ ] 整体符合主题 + +#### 详细指南 + +**完整的封面图设计原则、提示词模板、执行步骤**: + +👉 **参见** [references/cover-image-guide.md](references/cover-image-guide.md) + +包含: +- 5类文章的配色方案 +- 5个提示词模板(AI类、工具类、效率类、新闻类、教程类) +- 详细的生成步骤和质量验证方法 +- 常见问题排查 + +--- + +### 步骤6:根据内容生成其他配图(按需) + +**⚠️ 这是可选步骤**:仅在内容确实需要时才生成额外配图(0-2张)。 + +#### 决策规则 + +``` +阅读文章内容 + │ + ├─ 有明确数据对比? → 是 → 生成性能对比图 + │ + ├─ 有复杂技术架构? → 是 → 生成架构示意图 + │ + └─ 其他情况 → 不生成配图 +``` + +**典型场景**: +- 产品评测文章:封面图 + 性能对比图(共2张) +- 技术解析文章:封面图 + 技术架构图(共2张) +- 新闻资讯文章:仅封面图(共1张) +- 教程指南文章:仅封面图(共1张) + +#### 详细指南 + +**完整的内容配图类型、提示词模板、生成流程**: + +👉 **参见** [references/content-images-guide.md](references/content-images-guide.md) + +包含: +- 5种配图类型(柱状图、架构图、对比图、流程图、雷达图) +- 每种类型的提示词模板 +- 数据提取和验证方法 +- 嵌入文章的最佳实践 + +--- + +### 步骤7:输出文章 + +使用 `Write` 工具创建Markdown格式的文章文件: + +**文件内容结构**: +```markdown +# 文章标题 + +![封面图](cover.png) + +## 第一部分标题 + +正文内容... + +![配图1](comparison.png) + +*图:简短说明* + +## 第二部分标题 + +正文内容... + +## 总结 + +结尾总结段落... +``` + +**重要提醒**: +- ❌ 不要添加"参考资料"、"图片说明"、"延伸阅读"等额外章节 +- ❌ 不要使用markdown超链接格式 `[文本](URL)` +- ✅ 只输出:标题 + 封面图 + 正文 + 总结 +- ✅ 链接使用纯文本格式:`官方网站:https://example.com/` + +**输出文件**: +- 文章文件:`{主题名称}.md` +- 封面图:`cover.png` +- 内容配图(如有):`performance-comparison.png`、`architecture.png`等 + +--- + +## 质量检查清单 + +在输出前务必确认: + +### 内容质量 +- [ ] 内容完全用自己的语言表达,无大段照搬 +- [ ] 技术术语有通俗解释 +- [ ] 包含具体例子和应用场景 +- [ ] 事实信息准确无误 +- [ ] 文章结构清晰,易于阅读 +- [ ] 语言自然流畅,适合公众号风格 +- [ ] 字数在2000-3000字之间 + +### 图片质量(强制检查) +- [ ] ✅ **已生成主题封面图**(强制要求) +- [ ] 封面图颜色鲜明,有吸引力 +- [ ] 封面图中文文字清晰可读,无乱码 +- [ ] 封面图视觉重点突出,符合主题 +- [ ] 内容配图(如有)数据准确 +- [ ] 所有图片已保存到输出目录 +- [ ] 图片风格统一(配色、设计风格一致) + +### 格式规范 +- [ ] 封面图作为文章第一张图片(紧跟标题) +- [ ] 链接使用纯文本格式(不是markdown超链接) +- [ ] 没有添加"参考资料"、"图片说明"等额外章节 +- [ ] 文件命名规范(无中文特殊字符) + +--- + +## 参考文档导航 + +### 详细指南 +- **[writing-style.md](references/writing-style.md)** - 详细的写作风格指南和范例 +- **[cover-image-guide.md](references/cover-image-guide.md)** - 封面图生成完整指南(设计原则、提示词模板) +- **[content-images-guide.md](references/content-images-guide.md)** - 内容配图生成指南(判断标准、图表类型) +- **[image-guidelines.md](references/image-guidelines.md)** - 图片选择和处理标准(真实图片提取) +- **[ai-image-generation.md](references/ai-image-generation.md)** - AI图片生成技术细节 +- **[api-configuration.md](references/api-configuration.md)** - 生图API配置指南(Gemini/DALL-E密钥设置) +- **[fact-checking.md](references/fact-checking.md)** - 事实核查要点 + +### 使用示例 +- **[EXAMPLES.md](EXAMPLES.md)** - 完整的使用示例(3个不同类型的文章) + - 示例1:技术新闻/资讯类(VSCode更名事件) + - 示例2:AI大模型介绍(Claude Sonnet 4) + - 示例3:开发工具介绍(LangChain) + +### 实用脚本 +- **scripts/generate_image.py** - 生图API调用脚本(支持Gemini/DALL-E/Claude原生) +- **scripts/generate_cover_optimized.py** - 优化的封面图生成脚本 +- **scripts/generate_temp.py** - 临时图片生成工具 + +--- + +## 快速参考 + +### 文章类型决策树 + +``` +用户输入 + │ + ├─ 上传了 Word/PDF 文档? → 文档输入模式 + │ └─ 读取文档 → 提炼要点 → 补充搜索 → 创作文章 + │ └─ 配图:封面 + 可选内容配图(1-2张) + │ + └─ 仅提供话题关键词 + │ + ├─ 包含"最新"、"发布"、"更名" → 新闻资讯类 + │ └─ 搜索:官方公告 + 社区反应 + │ └─ 配图:仅封面图(1张) + │ + ├─ 是AI模型/工具名称 → 介绍类 + │ ├─ AI大模型 → 功能+评测+案例 + │ │ └─ 配图:封面 + 可选性能对比图(1-2张) + │ │ + │ └─ 开发工具 → 文档+教程+案例 + │ └─ 配图:封面 + 可选架构图(1-2张) + │ + └─ 是技术概念 → 概念科普 + └─ 搜索:定义+原理+应用 + └─ 配图:封面 + 可选概念对比图(1-2张) +``` + +### 封面图配色速查 + +| 文章类型 | 配色方案 | 色彩代码 | +|---------|---------|---------| +| AI/科技类 | 蓝紫渐变 | #1a1f5c → #7c3aed | +| 工具/效率类 | 绿橙渐变 | #10b981 → #f97316 | +| 数据/分析类 | 蓝绿渐变 | #0891b2 → #06b6d4 | +| 创意/设计类 | 粉紫渐变 | #ec4899 → #a855f7 | + +### 常用命令 + +**生成封面图(Gemini)**: +```bash +python scripts/generate_image.py \ + --prompt "提示词" \ + --api gemini \ + --output cover.png +``` + +**生成封面图(DALL-E高清)**: +```bash +python scripts/generate_image.py \ + --prompt "提示词" \ + --api dalle \ + --quality hd \ + --size 1792x1024 \ + --output cover.png +``` + +**生成封面图(豆包即梦/火山引擎)**: +```bash +# 设置API Key +export ARK_API_KEY="你的火山引擎API Key" + +# 生成图片(默认 2048x2048) +python scripts/generate_image.py \ + --prompt "提示词" \ + --api doubao \ + --model seedream-5-0 \ + --output cover.png +``` + +**可用模型**: +- `seedream-5-0` - Seedream 5.0(高质量,默认) +- `seedream-4-5` - Seedream 4.5 +- `seedream-4-0` - Seedream 4.0 +- `seedream-3-0` - Seedream 3.0 + +**尺寸要求**: +- 默认:2048x2048 +- 最小:1920x1920(需至少 3686400 像素) + +--- + +## 典型工作流示例 + +### 示例:AI大模型介绍文章 + +```python +# 步骤1:明确主题 +主题类型 = "AI大模型介绍" +目标读者 = "AI用户、技术爱好者" + +# 步骤2-3:搜索和抓取 +搜索("Claude Sonnet 4 官方介绍") +搜索("Claude Sonnet 4 vs GPT-4 性能对比") +抓取(官网产品页 + 评测文章 + API文档) + +# 步骤4:改写创作 +写作( + 引子="实际应用场景引入", + 正文="功能特点 + 性能对比 + 应用案例 + 上手指引", + 字数=2800 +) + +# 步骤5:生成封面图(强制) +generate_image( + prompt="Claude Sonnet 4 封面,蓝紫渐变,标题+副标题...", + api="gemini", + output="cover.png" +) + +# 步骤6:内容配图(按需) +if 文章有性能对比数据: + generate_image( + prompt="性能对比柱状图,Claude vs GPT vs Gemini...", + output="performance-comparison.png" + ) + +# 步骤7:输出 +write_file("Claude_Sonnet_4介绍.md", 文章内容) +``` + +--- + +## 注意事项 + +### ✅ 应该做的 + +1. **每次都生成封面图** - 这是强制要求,不可省略 +2. **验证中文清晰度** - 生成后检查文字是否清晰 +3. **控制图片数量** - 总数不超过3张(1封面 + 0-2内容) +4. **保持风格统一** - 如有多张配图,配色和设计语言要一致 +5. **链接用纯文本** - 不使用markdown超链接格式 + +### ❌ 不应该做的 + +1. **不要跳过封面图** - 即使时间紧也必须生成 +2. **不要过度配图** - 宁缺毋滥,没价值的图不生成 +3. **不要照搬原文** - 必须用自己的语言改写 +4. **不要添加额外章节** - 如"参考资料"、"图片说明" +5. **不要忽视质量检查** - 输出前必须过一遍检查清单 + +--- + +## 提升质量的关键点 + +1. **选题要精准**:理解用户真正想了解什么 +2. **信息要准确**:事实和数据必须可靠 +3. **语言要通俗**:技术术语要解释,多用比喻 +4. **结构要清晰**:小标题、列表、图表帮助阅读 +5. **封面要吸睛**:配色鲜明、标题醒目、主题契合 + +--- + +**记住**:这个技能的目标是生成**高质量**、**易读**、**吸引人**的微信公众号科普文章。每个步骤都很重要,不可省略! diff --git a/cover.png b/cover.png new file mode 100644 index 0000000..3e715f7 Binary files /dev/null and b/cover.png differ diff --git a/references/ai-image-generation.md b/references/ai-image-generation.md new file mode 100644 index 0000000..c70ab12 --- /dev/null +++ b/references/ai-image-generation.md @@ -0,0 +1,702 @@ +# AI图片生成指南 + +## 概述 + +AI生成图片可以有效补充技术文章的视觉内容,特别适合创建封面图、概念示意图和场景插画。 + +**重要更新**:现在支持**直接调用生图API**生成真实图片并嵌入文章,而不仅仅是提供提示词! + +**支持的API**:Gemini Imagen、DALL-E、豆包即梦(火山引擎) + +## ⚠️ 重要优化原则(2025-12-27更新) + +### 1. 图片文字必须使用中文 +- **所有图片上的文字都必须使用简体中文** +- 文字数量要少,只保留关键信息 +- 文字必须准确无误,不能出现错别字或拼写错误 +- 在提示词中明确要求:"text in simplified Chinese, minimal text, accurate and clear" + +### 2. 只生成真正必要的图片 +**必要图片的判断标准**: +- ✅ **性能对比图**:有明确的数据对比时必须生成 +- ✅ **技术架构图**:涉及复杂技术原理需要可视化时生成 +- ✅ **封面图**:可选,仅在需要吸引眼球时生成 +- ❌ **装饰性配图**:不要生成纯装饰性的图片 +- ❌ **场景插画**:除非对理解内容有实质帮助,否则不生成 + +**生成决策流程**: +1. 阅读文章内容 +2. 判断是否有数据对比 → 是:生成对比图 +3. 判断是否有复杂技术 → 是:生成架构图 +4. 判断是否需要封面 → 视情况决定 +5. 其他图片一律不生成 + +**典型场景**: +- 产品评测文章:生成1-2张(封面图 + 性能对比图) +- 技术解析文章:生成1-2张(技术架构图 + 可选封面图) +- 新闻资讯文章:生成0-1张(可选封面图) + +### 3. 图片数量控制 +- 每篇文章图片数量:**1-3张**(之前是4-6张) +- 优先级:数据图 > 架构图 > 封面图 > 其他 +- 宁缺毋滥,质量优于数量 + +## 🚀 快速开始:调用生图API + +### 方式一:使用脚本调用外部API + +使用 `scripts/generate_image.py` 脚本可以直接调用 Gemini、DALL-E 或豆包(火山引擎)API: + +**基本用法**: +```bash +# 使用Gemini Imagen API (推荐) +python scripts/generate_image.py \ + --prompt "图片描述提示词" \ + --api gemini \ + --output /home/claude/images/cover.png + +# 使用DALL-E API (OpenAI) +python scripts/generate_image.py \ + --prompt "图片描述提示词" \ + --api dalle \ + --output /home/claude/images/cover.png + +# 使用豆包即梦 API (火山引擎) - 推荐国内用户 +python scripts/generate_image.py \ + --prompt "图片描述提示词" \ + --api doubao \ + --model seedream-5-0 \ + --output /home/claude/images/cover.png +``` + +**环境配置**: +```bash +# 使用Gemini需要设置 +export GEMINI_API_KEY="your-api-key" + +# 使用DALL-E需要设置 +export OPENAI_API_KEY="your-api-key" + +# 使用豆包即梦需要设置(火山引擎) +export ARK_API_KEY="your-ark-api-key" +``` + +**完整示例**: +```python +import subprocess +import os + +# 生成封面图 +subprocess.run([ + 'python', 'scripts/generate_image.py', + '--prompt', 'A modern cover image for an article about Claude AI. Style: minimalist, blue gradient.', + '--api', 'gemini', + '--output', '/home/claude/images/cover.png' +]) + +# 检查图片是否生成成功 +if os.path.exists('/home/claude/images/cover.png'): + print("✅ 封面图生成成功") +``` + +### 方式二:在claude.ai中使用Claude原生能力 + +如果在claude.ai环境中,可以直接使用Claude的图片生成能力(无需外部API): + +```markdown +请根据以下描述生成一张图片: +A modern cover image for an article about Claude AI. +Style: minimalist, professional, gradient blue background. +``` + +Claude会直接生成图片,然后保存到本地并在文章中引用。 + +### 支持的API对比 + +| API | 优势 | 劣势 | 推荐场景 | +|-----|------|------|---------| +| **Gemini Imagen** | 质量高,速度快,价格合理 | 需要Google API密钥 | 所有场景,首选 | +| **DALL-E 3** | 质量优秀,细节丰富 | 速度较慢,价格稍高 | 需要高质量封面图 | +| **Claude原生** | 无需外部API,方便 | 仅在claude.ai可用 | claude.ai环境 | +| **豆包即梦 (Seedream)** | 国内访问快,中文支持好,价格实惠 | 需要火山引擎ARK API Key | 国内用户首选 | + +### 豆包即梦(火山引擎)特别说明 + +**支持的模型**: +```bash +--model seedream-5-0 # Seedream 5.0(默认,高质量) +--model seedream-4-5 # Seedream 4.5 +--model seedream-4-0 # Seedream 4.0 +--model seedream-3-0 # Seedream 3.0 +``` + +**尺寸要求**: +- 默认尺寸:2048x2048 +- 最小尺寸:1920x1920(需至少 3,686,400 像素) +- 小尺寸会自动调整为 2048x2048 + +**完整示例**: +```bash +# 使用豆包即梦生成封面图 +ARK_API_KEY="your-ark-key" python scripts/generate_image.py \ + --prompt "OpenClaw AI agent framework cover, blue purple gradient, tech style" \ + --api doubao \ + --model seedream-5-0 \ + --output /tmp/cover.png +``` + +**API Key 获取**: +1. 登录 [火山引擎方舟控制台](https://www.volcengine.com/docs/82379) +2. 进入「API Key 管理」 +3. 创建或复制 API Key + +## 工作流集成 + +在文章生成流程中,图片生成步骤如下: + +```python +# 1. 确定需要的图片类型和提示词 +images_to_generate = [ + { + "type": "cover", + "prompt": "封面图提示词", + "output": "/home/claude/images/cover.png" + }, + { + "type": "concept", + "prompt": "概念图提示词", + "output": "/home/claude/images/concept.png" + }, + { + "type": "scene", + "prompt": "场景图提示词", + "output": "/home/claude/images/scene.png" + } +] + +# 2. 批量生成图片 +# 可选API: gemini, dalle, doubao +api_choice = "doubao" # 国内用户推荐使用豆包 + +for img in images_to_generate: + cmd = [ + 'python', 'scripts/generate_image.py', + '--prompt', img['prompt'], + '--api', api_choice, + '--output', img['output'] + ] + # 豆包需要指定model + if api_choice == "doubao": + cmd.extend(['--model', 'seedream-5-0']) + subprocess.run(cmd) + +# 3. 在文章中嵌入生成的图片 +article = f""" +# 文章标题 + +![封面图]({images_to_generate[0]['output']}) + +## 核心概念 + +![概念图]({images_to_generate[1]['output']}) + +## 应用场景 + +![场景图]({images_to_generate[2]['output']}) +""" + +# 4. 将图片复制到输出目录 +import shutil +for img in images_to_generate: + shutil.copy(img['output'], '/mnt/user-data/outputs/') +``` + +--- + +## 何时使用AI生成图片 + +### ✅ 适合AI生成的场景 + +1. **封面图/首图** + - 吸引读者点击的视觉设计 + - 体现文章主题的创意图 + - 品牌风格的标题图 + +2. **概念示意图** + - 抽象技术概念的可视化 + - 工作流程的示意图 + - 系统架构的简化表现 + +3. **场景插画** + - 使用场景的情景化展示 + - 问题场景的描绘 + - 解决方案的效果展示 + +4. **对比示意图** + - 功能对比的视觉化 + - 使用前后的对比 + - 不同方案的比较 + +5. **装饰性配图** + - 段落间的视觉分隔 + - 增强阅读体验的插图 + - 主题相关的背景图 + +### ❌ 不适合AI生成的场景 + +1. **实际产品截图** + - 软件界面必须用真实截图 + - 代码编辑器画面 + - 实际操作步骤 + +2. **真实数据图表** + - 性能测试数据 + - 市场占有率图表 + - GitHub Star趋势图 + +3. **官方品牌素材** + - 产品Logo + - 官方宣传图 + - 品牌标识 + +4. **技术细节图** + - 复杂的架构图(需要准确性) + - 详细的流程图 + - 代码结构图 + +## 技术文章的图片风格建议 + +### 整体风格原则 + +**推荐风格**: +- 🎨 **现代简约** - 干净、专业 +- 🎯 **科技感** - 体现技术主题 +- 📊 **信息清晰** - 易于理解 +- 🌈 **色彩统一** - 全文风格一致 + +**避免的风格**: +- ❌ 过于卡通或幼稚 +- ❌ 过度复杂或花哨 +- ❌ 色彩杂乱无章 +- ❌ 与技术主题无关 + +### 配色建议 + +**科技蓝色系**(适合AI、云计算、开发工具): +- 主色:深蓝 #1a73e8、科技蓝 #4285f4 +- 辅色:浅蓝 #e8f4ff、白色 #ffffff +- 点缀:橙色 #ff6b35(用于强调) + +**紫色渐变系**(适合AI、创新工具): +- 主色:深紫 #6366f1、亮紫 #a78bfa +- 辅色:浅紫 #f5f3ff、白色 +- 点缀:粉色 #ec4899 + +**绿色系**(适合数据、性能、效率): +- 主色:深绿 #059669、亮绿 #10b981 +- 辅色:浅绿 #d1fae5、白色 +- 点缀:黄色 #fbbf24 + +**黑白灰系**(适合严肃、专业内容): +- 主色:深灰 #1f2937、黑色 #000000 +- 辅色:浅灰 #f3f4f6、白色 +- 点缀:蓝色或绿色 + +## 不同类型图片的提示词模板 + +### 1. 封面图/首图 + +**目标**:吸引眼球,传达文章主题 + +**提示词模板**: +``` +A modern, clean cover image for a tech article about [主题]. +Style: minimalist, professional, tech-focused. +Color scheme: [蓝色/紫色/绿色] gradient background. +Elements: [关键元素,如AI brain, code symbols, cloud icons, etc.] +Text: minimal text in simplified Chinese only, accurate and clear. +Composition: centered, with copy space for title text. +High quality, 16:9 aspect ratio. +``` + +**⚠️ 中文文字要求**: +- 所有提示词必须包含:"text in simplified Chinese, minimal text, accurate" +- 图片上的文字要少而精,仅保留核心信息 +- 避免复杂长句,使用简短词汇 + +**具体示例**: + +**示例1 - AI模型文章封面**: +``` +A modern, clean cover image for a tech article about Claude AI assistant. +Style: minimalist, professional, futuristic. +Color scheme: gradient from deep blue (#1a73e8) to light blue (#e8f4ff). +Elements: abstract AI neural network visualization, glowing nodes and connections, subtle circuit patterns in background. +Composition: centered abstract design with space at top for article title. +Mood: innovative, intelligent, approachable. +High quality, 16:9 aspect ratio, professional tech illustration. +``` + +**示例2 - 开源工具封面**: +``` +A modern cover image for an article about LangChain framework. +Style: clean, professional, developer-focused. +Color scheme: dark background (#1f2937) with bright green (#10b981) and blue (#4285f4) accents. +Elements: connected chain links representing workflow, code brackets, small icons of tools/modules. +Composition: horizontal layout with geometric shapes, space for title on left. +Mood: powerful, flexible, interconnected. +High quality, 16:9 aspect ratio. +``` + +### 2. 概念示意图 + +**目标**:可视化抽象概念,帮助理解 + +**提示词模板**: +``` +A simple, clear diagram illustrating [概念/原理]. +Style: infographic, clean lines, minimal text. +Color scheme: [2-3种颜色]. +Elements: [具体元素,如arrows, boxes, icons]. +Layout: [flow chart / circular / hierarchical]. +Professional, easy to understand, tech illustration style. +``` + +**具体示例**: + +**示例1 - 工作流程图**: +``` +A clean diagram showing how LangChain processes user requests. +Style: flowchart with rounded boxes and arrows, modern infographic style. +Color scheme: white background, blue boxes (#4285f4), green success arrows (#10b981), orange highlights (#ff6b35). +Elements: 4-5 connected steps from left to right - User Input → LLM Processing → Tool Integration → Response Output. +Include simple icons in each box (message icon, brain icon, tools icon, checkmark). +Clean, professional, easy to read, tech documentation style. +Aspect ratio: 16:9, horizontal layout. +``` + +**示例2 - 架构示意图**: +``` +A simplified architecture diagram showing three-tier application structure. +Style: modern technical illustration, isometric or flat design. +Color scheme: dark blue background (#1a73e8), white/light blue components. +Elements: three distinct layers (Frontend, Backend, Database) represented as boxes or platforms, with bidirectional arrows showing data flow. +Include minimal icons (browser, server, database symbols). +Clean, professional, suitable for tech documentation. +No text labels needed - keep it visual. +Aspect ratio: 16:9 or 1:1. +``` + +### 3. 场景插画 + +**目标**:展示实际应用场景,增加代入感 + +**提示词模板**: +``` +An illustration showing [使用场景]. +Style: modern flat design / isometric illustration. +Color scheme: [温暖/科技感的配色]. +Characters: [可选:简化的人物剪影]. +Environment: [办公室/家庭/移动场景]. +Mood: [productive / innovative / user-friendly]. +Clean, professional, tech article illustration. +``` + +**具体示例**: + +**示例1 - 开发者使用场景**: +``` +An illustration of a developer using AI coding assistant at desk. +Style: modern flat design illustration, simple and clean. +Color scheme: purple gradient background (#6366f1 to #a78bfa), white desk, laptop. +Scene: minimalist home office setup, developer silhouette facing laptop, subtle AI sparkles/glow from screen. +Mood: focused, productive, empowered by technology. +No facial details needed - keep it simple and professional. +Aspect ratio: 16:9, horizontal composition. +``` + +**示例2 - 多设备使用场景**: +``` +An isometric illustration showing cross-platform application usage. +Style: clean isometric design, tech-focused. +Color scheme: light background with blue (#4285f4) and green (#10b981) device screens. +Elements: smartphone, tablet, laptop arranged in a connected layout, subtle data flow lines between devices. +Mood: connected, seamless, modern. +Professional tech illustration, minimal details. +Aspect ratio: 1:1 or 16:9. +``` + +### 4. 对比示意图 + +**目标**:清晰展示差异或改进 + +**提示词模板**: +``` +A before/after or comparison illustration showing [对比内容]. +Style: split-screen or side-by-side layout. +Color scheme: [左侧/before用暗色或红色,右侧/after用亮色或绿色]. +Elements: clearly distinguishable visual differences. +Labels: minimal, use visual cues like ✗ and ✓. +Professional comparison infographic style. +``` + +**具体示例**: + +**示例1 - 性能对比**: +``` +A split-screen comparison: slow process vs fast process. +Style: minimalist infographic, clear visual contrast. +Color scheme: left side - gray/red tones showing slowness, right side - green/blue showing speed. +Left: loading spinner, progress bar at 30%, clock showing long time. +Right: checkmark, completed progress bar, clock showing short time. +Include simple speed indicators: tortoise icon left, rocket icon right. +Clean, professional, no text needed - purely visual. +Aspect ratio: 16:9, equal split down the middle. +``` + +**示例2 - 功能对比**: +``` +A side-by-side comparison of limited features vs full features. +Style: modern infographic, checklist visual. +Color scheme: white background, left boxes in gray with red ✗, right boxes in blue with green ✓. +Layout: 2 columns, 5 rows of feature boxes showing contrast. +Keep it abstract - use icons and checkmarks instead of text. +Professional, clean, tech comparison chart style. +Aspect ratio: 9:16 vertical or 1:1 square. +``` + +### 5. 装饰性配图 + +**目标**:美化排版,提升视觉体验 + +**提示词模板**: +``` +An abstract, decorative background for [主题] section. +Style: subtle, non-distracting, modern. +Color scheme: [柔和的渐变或单色]. +Elements: [几何图形/流线/粒子效果]. +Mood: professional, calm, tech-related. +Can be used as section divider or background. +``` + +**具体示例**: + +**示例1 - 段落分隔图**: +``` +An abstract tech-themed divider image. +Style: minimalist geometric design, horizontal orientation. +Color scheme: gradient from blue (#1a73e8) to purple (#6366f1). +Elements: flowing lines, subtle circuit patterns, small glowing dots. +Composition: horizontal banner, very subtle and not distracting. +Can be used between article sections. +Aspect ratio: 21:9 ultra-wide, very flat. +Professional, modern, suitable for tech blog. +``` + +**示例2 - 背景纹理**: +``` +A subtle tech pattern background. +Style: minimalist, repeating pattern or gradient. +Color scheme: very light - soft blue (#e8f4ff) to white, or light gray (#f3f4f6). +Elements: faint grid lines, tiny dots, or subtle geometric shapes. +Very low contrast - should not distract from text. +Suitable as section background in article. +Seamless, tileable pattern. +High quality but subtle presence. +``` + +## 风格统一性建议 + +为确保全文图片风格一致: + +### 1. 确定主色调 + +在开始生成前,选择一个主色调贯穿全文: +- **AI/大模型文章**:蓝紫色系 +- **开发工具文章**:蓝绿色系 +- **性能/数据文章**:绿色系 +- **企业级工具**:黑灰蓝色系 + +### 2. 统一设计风格 + +整篇文章选择一种风格并坚持: +- **扁平化设计** (Flat Design) +- **等距插画** (Isometric) +- **渐变风格** (Gradient) +- **极简主义** (Minimalist) + +### 3. 一致的复杂度 + +- 如果封面用简约风格,其他图也要简约 +- 避免一张图很复杂,另一张很简单 +- 保持视觉密度的一致性 + +### 4. 统一的提示词要素 + +在每个提示词中重复这些要素: +``` +Style: [统一的风格描述] +Color scheme: [统一的配色] +Mood: professional, modern, tech-focused +Quality: high quality, clean, suitable for tech article +``` + +## 图片生成工作流 + +### Step 1: 规划图片需求 + +阅读完成的文章草稿,列出需要的图片: + +**示例规划表**: +``` +1. 封面图 - 主题:Claude AI - 类型:封面 - 风格:科技蓝 +2. 概念图 - 展示:工作原理 - 类型:流程图 - 风格:科技蓝 +3. 场景图 - 展示:使用场景 - 类型:插画 - 风格:科技蓝 +4. 对比图 - 展示:性能提升 - 类型:对比 - 风格:科技蓝 +``` + +### Step 2: 选择主色调和风格 + +基于文章主题选择: +- 主色调:例如 科技蓝 (#1a73e8, #4285f4, #e8f4ff) +- 设计风格:例如 现代扁平化设计 +- 情绪基调:专业、创新、易用 + +### Step 3: 编写统一的提示词 + +为每张图编写提示词,确保包含统一要素: + +**提示词检查清单**: +- [ ] 明确了图片类型和内容 +- [ ] 指定了统一的风格 +- [ ] 使用了统一的配色方案 +- [ ] 说明了构图和比例 +- [ ] 标注了质量要求 +- [ ] 确保了与主题的相关性 + +### Step 4: 生成并检查 + +生成后检查: +- ✅ 风格是否一致 +- ✅ 色调是否协调 +- ✅ 清晰度是否足够 +- ✅ 是否与内容相关 +- ✅ 是否适合公众号排版 + +### Step 5: 嵌入文章并标注 + +在文章中嵌入图片时: +```markdown +![图1:Claude AI工作原理示意图](image_url) +*AI生成图片:展示Claude的核心工作流程* +``` + +## 提示词优化技巧 + +### 1. 具体而非抽象 + +❌ "A nice tech image" +✅ "A clean infographic showing data flow with blue arrows on white background" + +### 2. 描述风格参考 + +❌ "Modern style" +✅ "Modern flat design illustration, similar to tech blog graphics, professional and clean" + +### 3. 明确构图 + +❌ "Some icons" +✅ "Three icons arranged horizontally in the center, equal spacing, on gradient background" + +### 4. 控制复杂度 + +❌ "Complex system architecture" +✅ "Simplified 3-tier architecture with 3 main components and connecting arrows" + +### 5. 指定情绪和氛围 + +❌ "Tech background" +✅ "Tech background with mood: innovative, trustworthy, user-friendly" + +## 常见问题处理 + +### Q: 生成的图片太复杂了怎么办? + +A: 在提示词中强调: +- "minimalist" +- "simple" +- "clean design" +- "maximum 5 elements" + +### Q: 颜色不够统一? + +A: 明确指定颜色代码: +- "Color scheme: only use #1a73e8 (blue), #ffffff (white), and #000000 (black)" + +### Q: 图片和文章主题不搭? + +A: 在提示词开头明确主题: +- "For an article about [具体主题]..." +- "In the context of [技术领域]..." + +### Q: 风格不够专业? + +A: 添加质量描述词: +- "professional tech illustration" +- "suitable for enterprise blog" +- "high-quality documentation style" + +## 输出格式示例 + +在文章中整合AI生成图片时的格式: + +```markdown +## 核心功能 + +Claude Sonnet 4拥有强大的多模态理解能力: + +![图1:Claude多模态处理能力示意图](image_url) +*AI生成概念图:展示Claude如何同时处理文本、图片和文档* + +如上图所示,Claude可以... + +--- + +## 文章配图列表 + +### 真实截图(来自官方/网络) +1. **GitHub仓库首页** + - 来源:抓取自官方 + - 图片URL: https://... + +### AI生成图片 +1. **封面图** + - 类型:AI生成 + - 主题:Claude AI助手 + - 风格:科技蓝渐变,现代简约 + - 用途:文章开头 + +2. **工作原理图** + - 类型:AI生成 + - 内容:多模态处理流程 + - 风格:蓝色信息图 + - 用途:"核心功能"部分 + +3. **应用场景图** + - 类型:AI生成 + - 内容:开发者使用场景 + - 风格:扁平化插画 + - 用途:"使用场景"部分 +``` + +## 最佳实践总结 + +1. ✅ **混合使用**:真实截图 + AI生成图,各取所长 +2. ✅ **提前规划**:先确定需要哪些图,再统一生成 +3. ✅ **风格统一**:全文使用相同的色系和风格 +4. ✅ **简约优先**:技术文章配图宜简不宜繁 +5. ✅ **标注来源**:清楚标明哪些是AI生成 +6. ✅ **质量检查**:生成后检查清晰度和相关性 +7. ✅ **适度装饰**:不要为了配图而配图 + +通过合理使用AI生成图片,可以让技术文章更加生动专业,同时保持高效的创作流程! diff --git a/references/api-configuration.md b/references/api-configuration.md new file mode 100644 index 0000000..c4b0a74 --- /dev/null +++ b/references/api-configuration.md @@ -0,0 +1,255 @@ +# API配置指南 + +本文档说明如何配置生图API密钥,以便skill能够直接调用API生成图片。 + +## 支持的生图API + +目前skill支持以下生图API: + +1. **Gemini Imagen API** (Google) - 推荐 +2. **DALL-E 3 API** (OpenAI) +3. **Claude原生** (仅在claude.ai环境中) + +## 配置步骤 + +### 方式一:Gemini Imagen API (推荐) + +#### 1. 获取API密钥 + +访问 [Google AI Studio](https://aistudio.google.com/app/apikey) 获取API密钥。 + +#### 2. 设置环境变量 + +在使用前,需要设置环境变量: + +**Linux/Mac**: +```bash +export GEMINI_API_KEY="your-gemini-api-key-here" +``` + +**Windows (PowerShell)**: +```powershell +$env:GEMINI_API_KEY="your-gemini-api-key-here" +``` + +**在Claude中设置** (如果Claude环境支持): +```python +import os +os.environ['GEMINI_API_KEY'] = 'your-gemini-api-key-here' +``` + +#### 3. 测试配置 + +```bash +python scripts/generate_image.py \ + --prompt "A simple blue gradient background" \ + --api gemini \ + --output test.png +``` + +如果看到 `✅ 图片已生成: test.png`,说明配置成功! + +#### 价格参考 + +- Imagen 3.0: 约 $0.04 per image (标准质量) +- 比DALL-E更实惠 + +### 方式二:DALL-E API (OpenAI) + +#### 1. 获取API密钥 + +访问 [OpenAI Platform](https://platform.openai.com/api-keys) 创建API密钥。 + +#### 2. 设置环境变量 + +**Linux/Mac**: +```bash +export OPENAI_API_KEY="sk-your-openai-api-key" +``` + +**Windows (PowerShell)**: +```powershell +$env:OPENAI_API_KEY="sk-your-openai-api-key" +``` + +**在Claude中设置**: +```python +import os +os.environ['OPENAI_API_KEY'] = 'sk-your-openai-api-key' +``` + +#### 3. 测试配置 + +```bash +python scripts/generate_image.py \ + --prompt "A simple blue gradient background" \ + --api dalle \ + --quality standard \ + --output test.png +``` + +#### 价格参考 + +- DALL-E 3 标准质量: $0.04 per image (1024x1024) +- DALL-E 3 HD质量: $0.08 per image (1024x1024) +- 更大尺寸价格更高 + +### 方式三:Claude原生 (仅claude.ai) + +如果你在claude.ai环境中使用,可以直接使用Claude的图片生成能力,无需额外配置: + +```python +# 在claude.ai中,直接请求生成图片 +# Claude会使用原生能力生成 +``` + +不需要设置任何API密钥。 + +## 在Skill中使用 + +### 自动检测可用API + +Skill会按以下优先级自动选择可用的API: + +1. 检查 `GEMINI_API_KEY` 是否设置 → 使用Gemini +2. 检查 `OPENAI_API_KEY` 是否设置 → 使用DALL-E +3. 如果在claude.ai环境 → 使用Claude原生 +4. 如果都不可用 → 提供提示词,不生成真实图片 + +### 手动指定API + +你也可以在请求时指定使用哪个API: + +``` +写一篇关于XXX的文章,使用Gemini API生成图片 +``` + +或 + +``` +写一篇关于XXX的文章,使用DALL-E生成图片 +``` + +## 成本估算 + +假设一篇文章需要生成4张AI图片: + +| API | 单张价格 | 4张总价 | 质量 | 速度 | +|-----|---------|---------|------|------| +| Gemini Imagen | ~$0.04 | ~$0.16 | ⭐⭐⭐⭐ | ⚡⚡⚡ | +| DALL-E 3 标准 | $0.04 | $0.16 | ⭐⭐⭐⭐⭐ | ⚡⚡ | +| DALL-E 3 HD | $0.08 | $0.32 | ⭐⭐⭐⭐⭐ | ⚡⚡ | +| Claude原生 | 免费* | 免费* | ⭐⭐⭐⭐ | ⚡⚡⚡ | + +*Claude原生功能可能受订阅计划限制 + +## 常见问题 + +### Q: 如何查看我的API配额? + +**Gemini**: +- 访问 [Google AI Studio](https://aistudio.google.com/) +- 查看"Quotas"标签页 + +**DALL-E**: +- 访问 [OpenAI Usage Dashboard](https://platform.openai.com/usage) + +### Q: API调用失败怎么办? + +1. **检查API密钥是否正确** + ```bash + echo $GEMINI_API_KEY # 或 $OPENAI_API_KEY + ``` + +2. **查看错误信息** + 脚本会显示详细的错误信息,如: + - `401 Unauthorized` → API密钥无效 + - `429 Too Many Requests` → 超过配额限制 + - `503 Service Unavailable` → API服务暂时不可用 + +3. **降级方案** + 如果API不可用,skill会自动降级为仅提供提示词模式。 + +### Q: 可以使用其他生图API吗? + +可以!你可以修改 `scripts/generate_image.py` 添加其他API支持,如: +- Stability AI (Stable Diffusion) +- Midjourney API +- Azure OpenAI +- 其他自定义API + +只需按照脚本中的`ImageGenerator`基类实现即可。 + +### Q: 生成的图片保存在哪里? + +默认保存在 `/home/claude/images/` 目录,同时会复制到 `/mnt/user-data/outputs/` 供用户下载。 + +### Q: 可以批量生成图片吗? + +可以!脚本支持在循环中调用: + +```python +prompts = ["提示词1", "提示词2", "提示词3"] +for i, prompt in enumerate(prompts): + subprocess.run([ + 'python', 'scripts/generate_image.py', + '--prompt', prompt, + '--api', 'gemini', + '--output', f'/home/claude/images/img_{i}.png' + ]) +``` + +## 最佳实践 + +1. **优先使用Gemini** + - 性价比高 + - 速度快 + - 质量稳定 + +2. **重要封面用DALL-E HD** + - 质量最高 + - 细节丰富 + - 适合重点文章 + +3. **测试环境用Claude原生** + - 无需配置 + - 快速验证 + - 适合原型开发 + +4. **批量生成做好错误处理** + ```python + try: + result = subprocess.run([...], check=True) + except subprocess.CalledProcessError: + print("生成失败,使用备选方案") + ``` + +5. **缓存生成的图片** + - 相同提示词不重复生成 + - 节省成本 + - 提高效率 + +## 安全提醒 + +⚠️ **不要将API密钥提交到版本控制** + +在 `.gitignore` 中添加: +``` +.env +*.key +secrets/ +``` + +使用环境变量或配置文件管理API密钥。 + +## 技术支持 + +如遇到问题: +1. 查看脚本输出的错误信息 +2. 检查API文档是否有更新 +3. 验证API密钥是否有效 +4. 确认API配额是否充足 + +--- + +配置完成后,skill就能自动调用生图API,为文章生成精美的配图了!🎨 diff --git a/references/content-images-guide.md b/references/content-images-guide.md new file mode 100644 index 0000000..64ebe36 --- /dev/null +++ b/references/content-images-guide.md @@ -0,0 +1,631 @@ +# 内容配图生成指南 + +> **核心原则**:宁缺毋滥,质量优于数量。只在真正需要时才生成内容配图(0-2张)。 + +--- + +## 一、判断是否需要内容配图 + +### 决策流程图 + +``` +┌─────────────────────┐ +│ 阅读文章正文内容 │ +└──────────┬──────────┘ + │ + ┌──────▼──────┐ + │ 是否有明确的 │ + │ 数据对比? │ + └──┬───────┬──┘ + │ │ + 是 否 + │ │ + 生成对比图 │ + │ ┌──▼──────┐ + │ │是否有复杂│ + │ │技术架构?│ + │ └──┬───┬──┘ + │ │ │ + │ 是 否 + │ │ │ + │ 生成 │ + │ 架构图 │ + │ │ │ + ┌──▼───────▼───▼─┐ + │ 其他情况一律 │ + │ 不生成配图 │ + └─────────────────┘ +``` + +### 生成内容配图的典型场景 + +#### 场景1:性能/数据对比 + +**何时生成**: +- 文章中提到多个产品/模型的性能数据 +- 有明确的指标对比(速度、准确率、成本等) +- 数字较多,纯文字不够直观 + +**示例触发条件**: +```markdown +# 文章中出现类似内容 +"Claude Sonnet 4在推理速度上比GPT-4快30%,比Gemini Pro快15%..." +"VSCode的启动时间从2.3秒降至0.8秒..." +"Cursor的用户满意度达到92%,而VSCode为87%..." +``` + +**生成内容**:横向对比柱状图、雷达图、性能曲线图 + +#### 场景2:技术架构说明 + +**何时生成**: +- 介绍系统架构、框架设计 +- 解释复杂的数据流向、调用关系 +- 说明多层次的技术栈 + +**示例触发条件**: +```markdown +# 文章中出现类似内容 +"VSCode的AI功能分为三层:UI层、Agent层、模型层..." +"数据处理流程:采集 → 清洗 → 转换 → 加载..." +"微服务架构包括:API网关、服务注册中心、配置中心..." +``` + +**生成内容**:架构示意图、流程图、层次结构图 + +#### 场景3:概念对比/前后差异 + +**何时生成**: +- 对比新旧两种方式 +- 解释范式转变 +- 说明升级带来的变化 + +**示例触发条件**: +```markdown +# 文章中出现类似内容 +"传统编程 vs Vibe Coding" +"手动配置 vs 自动化配置" +"单体应用 vs 微服务架构" +``` + +**生成内容**:左右对比图、before/after图 + +### 不应该生成配图的情况 + +❌ **不要生成的场景**: + +1. **装饰性配图** + - 仅为美观,不传达信息 + - 通用的科技插画、人物剪影 + - 与内容关系不大的背景图 + +2. **重复性配图** + - 已有封面图表达了相同主题 + - 与文字描述完全一致,没有额外信息 + +3. **简单文字可说清的内容** + - 简单列表(3-5项)用文字更清晰 + - 单一步骤流程 + - 仅有1-2个数据点 + +4. **场景插画** + - "一个人在电脑前工作" + - "团队开会讨论" + - "未来城市科技场景" + +### 配图数量控制 + +| 文章类型 | 封面图 | 内容配图 | 总计 | 说明 | +|---------|-------|---------|------|------| +| **产品评测** | 1张(强制) | 0-2张 | 1-3张 | 性能对比图、功能对比图 | +| **技术解析** | 1张(强制) | 0-2张 | 1-3张 | 架构图、流程图 | +| **新闻资讯** | 1张(强制) | 0张 | 1张 | 新闻类不需要内容配图 | +| **教程指南** | 1张(强制) | 0-1张 | 1-2张 | 流程图(可选),步骤用文字 | +| **概念科普** | 1张(强制) | 0-1张 | 1-2张 | 概念对比图(可选) | + +**关键原则**:内容配图总数不超过2张(封面图除外) + +--- + +## 二、内容配图的类型和提示词 + +### 类型1:性能对比柱状图 + +**适用场景**:对比3-5个产品/模型的性能指标 + +**提示词模板**: +``` +A clean performance comparison chart for [主题]. +Design: horizontal bar chart with 3-4 bars, each representing a different [产品/模型]. +Style: minimalist, professional data visualization with gradient fills. +Color scheme: gradient from blue (#3b82f6) to purple (#7c3aed) for bars. +Elements: +- Y-axis: product names in simplified Chinese ([产品1], [产品2], [产品3]) +- X-axis: performance metric in Chinese ([指标名称,如"响应速度(ms)"]) +- Bar labels: exact values at the end of each bar +- Legend: simple and clear in Chinese +Visual style: modern, clean, corporate presentation quality. +Background: white or light gradient, not distracting. +All text in simplified Chinese, accurate and clear. +16:9 aspect ratio, high contrast for readability. +``` + +**变量填充示例**: +``` +[主题] = "AI模型响应速度对比" +[产品1] = "Claude Sonnet 4" +[产品2] = "GPT-4 Turbo" +[产品3] = "Gemini Pro" +[指标名称] = "响应时间(秒)" +``` + +**设计要点**: +- 最慢的数据放最上方,最快的放最下方(或反之,保持一致) +- 使用渐变色而非纯色(更现代) +- 数值要清晰标注 +- 避免3D效果(难以准确读数) + +### 类型2:技术架构图 + +**适用场景**:展示系统分层、模块关系、数据流 + +**提示词模板**: +``` +A modern technical architecture diagram for [系统名称]. +Design: layered architecture with 3-4 tiers, connected by arrows showing data flow. +Style: clean, professional, developer-oriented. +Layers from top to bottom: +- [层级1]: [组件名称] - represented as rounded rectangles +- [层级2]: [组件名称] - represented as rounded rectangles +- [层级3]: [组件名称] - represented as rounded rectangles +Visual elements: +- Arrows showing data flow direction (with Chinese labels like "数据流", "API调用") +- Color coding: each layer has a distinct color (blue, green, orange) +- Icons: subtle tech icons for each component (API, database, UI) +Style: flat design with subtle shadows, modern and clean. +Background: light gradient, not distracting. +All text in simplified Chinese, clear labels. +16:9 aspect ratio, high quality. +``` + +**变量填充示例**: +``` +[系统名称] = "VSCode AI架构" +[层级1] = "UI层:编辑器界面、Chat面板" +[层级2] = "Agent层:Copilot、任务执行器" +[层级3] = "模型层:Claude、GPT、Gemini" +``` + +**设计要点**: +- 从上到下或从左到右的清晰流向 +- 每层用不同颜色区分 +- 箭头明确标注数据流向 +- 避免过于复杂(不超过10个模块) + +### 类型3:概念对比图(左右对比) + +**适用场景**:对比两种方式、新旧差异、优劣分析 + +**提示词模板**: +``` +A clear comparison image showing [概念A] vs [概念B]. +Layout: split screen design, left side for [概念A], right side for [概念B]. +Design: +- Left side: [概念A的视觉表现,如"传统编程:一行行代码"] + - Color: cooler tones (blue-gray) representing traditional/old + - Visual: [具体视觉元素] +- Right side: [概念B的视觉表现,如"Vibe Coding:对话框和AI"] + - Color: warmer/brighter tones (green-blue) representing modern/new + - Visual: [具体视觉元素] +- Center: "VS" or arrow showing transformation +Text labels: +- Left: "[概念A名称]" in Chinese +- Right: "[概念B名称]" in Chinese +- Optional: key differences listed below each side in Chinese +Style: clean, modern, infographic-style, easy to understand. +All text in simplified Chinese, clear and readable. +16:9 aspect ratio. +``` + +**变量填充示例**: +``` +[概念A] = "传统编程" +[概念A的视觉表现] = "code editor with lines of code, manual typing" +[概念B] = "Vibe Coding" +[概念B的视觉表现] = "chat interface with AI assistant, natural language commands" +``` + +**设计要点**: +- 左右明显区分(颜色、风格) +- 中间的VS或箭头醒目 +- 关键差异点简洁列出(不超过5点) + +### 类型4:流程图 + +**适用场景**:展示工作流程、数据处理步骤 + +**提示词模板**: +``` +A modern workflow diagram for [流程名称]. +Design: horizontal flow from left to right with 4-6 steps. +Steps: +1. [步骤1] - represented as rounded rectangle with icon +2. [步骤2] - represented as rounded rectangle with icon +3. [步骤3] - represented as rounded rectangle with icon +4. [步骤4] - represented as rounded rectangle with icon +Visual elements: +- Arrows connecting steps (left to right, bold and clear) +- Icons inside each step box (search, process, write, check) +- Color gradient: steps transition from blue to green across the flow +- Chinese labels inside and below each step +Style: clean, modern, professional process diagram. +Background: white or subtle gradient. +All text in simplified Chinese, clear and concise. +16:9 aspect ratio. +``` + +**设计要点**: +- 步骤数量:4-6步(不超过8步) +- 箭头清晰,流向明确 +- 每步配一个图标增强识别性 +- 颜色渐变显示进展 + +### 类型5:数据雷达图(多维对比) + +**适用场景**:对比多个产品在多个维度的表现 + +**提示词模板**: +``` +A professional radar chart comparing [对比主题]. +Design: spider/radar chart with 5-6 dimensions, showing 2-3 products. +Dimensions (axes): +- [维度1,如"性能"] +- [维度2,如"易用性"] +- [维度3,如"成本"] +- [维度4,如"生态"] +- [维度5,如"扩展性"] +Products (lines): +- [产品1]: blue line (#3b82f6) +- [产品2]: purple line (#7c3aed) +- [产品3]: green line (#10b981) +Visual elements: +- Semi-transparent fill for each product +- Clear legend in Chinese +- Axis labels in Chinese +- Grid lines for reference (subtle) +Style: modern, professional, data visualization quality. +All text in simplified Chinese. +Square aspect ratio (1:1), high quality. +``` + +**设计要点**: +- 维度数:5-6个(太少失去意义,太多难以阅读) +- 产品数:2-3个(不超过4个) +- 使用半透明填充,多条线重叠时仍可见 +- 每个维度的量表一致(如都是0-10分) + +--- + +## 三、生成执行步骤 + +### 步骤1:从文章中提取数据 + +**数据收集清单**: + +如果是对比图: +- [ ] 产品/模型名称(2-5个) +- [ ] 对比指标(响应时间、准确率、价格等) +- [ ] 具体数值(带单位) +- [ ] 数据来源(确保准确性) + +如果是架构图: +- [ ] 系统名称 +- [ ] 层级划分(2-4层) +- [ ] 每层的主要组件 +- [ ] 组件间的关系和数据流向 + +如果是流程图: +- [ ] 流程名称 +- [ ] 主要步骤(4-6步) +- [ ] 每步的简短描述 +- [ ] 步骤顺序和依赖关系 + +### 步骤2:选择合适的图表类型 + +**决策矩阵**: + +| 数据特征 | 推荐图表类型 | 原因 | +|---------|-------------|------| +| 2-5个产品,单一指标 | 横向柱状图 | 直观,易对比 | +| 2-3个产品,多维度 | 雷达图 | 全面展示优势劣势 | +| 分层结构 | 架构图 | 清晰显示层次关系 | +| 顺序步骤 | 流程图 | 强调先后顺序 | +| 新旧对比 | 左右对比图 | 突出差异 | + +### 步骤3:构建提示词 + +**组装检查清单**: +- [ ] 选择了正确的模板 +- [ ] 填充了所有变量(产品名、指标名等) +- [ ] 强调了中文要求 +- [ ] 指定了配色方案 +- [ ] 明确了图表类型(bar chart, architecture diagram等) +- [ ] 包含质量关键词(professional, clean, modern) + +**提示词质量自检**: +1. 是否包含"simplified Chinese"至少2次? +2. 是否明确了颜色代码或配色方案? +3. 是否指定了具体的图表类型? +4. 是否限制了元素数量(避免过于复杂)? + +### 步骤4:调用API生成 + +```bash +python scripts/generate_image.py \ + --prompt "你构建的完整提示词" \ + --api gemini \ + --output "输出路径/comparison.png" +``` + +**参数建议**: +- 对比图、流程图:使用16:9比例(`--aspect-ratio 16:9`) +- 雷达图、架构图:可使用1:1比例(更紧凑) + +### 步骤5:验证和优化 + +**验证清单**: +- [ ] 数据准确(数值、名称与文章一致) +- [ ] 中文清晰(无乱码、可读) +- [ ] 视觉清晰(元素不重叠、对比度足够) +- [ ] 配色合理(与封面图风格协调) +- [ ] 传达信息明确(读者一眼能看懂) + +**常见问题修复**: + +| 问题 | 修复方法 | +|------|---------| +| 数据错误 | 重新生成,提示词中强调准确数据:"exactly these values: A=90, B=85, C=78" | +| 文字太小 | 强调:"large, readable labels" | +| 颜色混乱 | 指定具体色彩代码:"use only #3b82f6, #7c3aed, #10b981" | +| 太复杂 | 简化:"show only 3 products, 4 metrics maximum" | + +--- + +## 四、嵌入文章的最佳实践 + +### 嵌入位置 + +**原则**:图片应紧跟相关文字段落之后 + +**示例**: +```markdown +## VSCode与Cursor的性能对比 + +在响应速度方面,VSCode最新版本表现出色。根据测试数据, +VSCode的启动时间为0.8秒,比Cursor的1.2秒快33%。在代码 +补全延迟方面,VSCode平均为150ms,而Cursor为180ms。 + +![性能对比图](performance-comparison.png) + +*图:VSCode vs Cursor 性能对比* + +从数据可以看出,VSCode在性能优化上已经赶上并超越了Cursor... +``` + +### 图注(Caption)规范 + +**格式**: +```markdown +![图片描述](image.png) + +*图X:简短的图片说明* +``` + +**图注内容**: +- 简洁说明(不超过15字) +- 不重复图片中已有的信息 +- 可选:数据来源 + +**示例**: +```markdown +✅ 好的图注 +*图1:主流AI模型响应速度对比(单位:毫秒)* + +❌ 不好的图注 +*图1:这张图展示了Claude Sonnet 4、GPT-4和Gemini Pro三个模型在响应速度方面的详细对比,可以看出Claude最快* +(太啰嗦,信息已在图中) +``` + +### 文件命名规范 + +**命名模式**:`{类型}-{主题}.png` + +**示例**: +``` +performance-comparison.png # 性能对比图 +architecture-diagram.png # 架构图 +workflow.png # 流程图 +before-after-comparison.png # 前后对比图 +``` + +**避免**: +``` +image1.png # 无意义的名称 +图片_final_v2.png # 混用中英文、版本号 +``` + +### 图片大小控制 + +**目标**: +- 封面图:500-800KB +- 内容配图:200-500KB +- 总计:< 2MB + +**过大时压缩**: +```bash +# 使用ImageMagick压缩(如果可用) +convert input.png -quality 85 -resize 1920x1080 output.png +``` + +--- + +## 五、高级技巧 + +### 技巧1:数据可视化颜色选择 + +**颜色语义**: +- 蓝色:稳定、可靠、专业(适合主导产品) +- 绿色:增长、正面、环保(适合性能提升) +- 橙色:警示、次要、中性(适合对比项) +- 红色:警告、减少、负面(慎用) +- 紫色:创新、高端、未来(适合新技术) + +**对比配色方案**: +- 蓝 vs 紫:#3b82f6 vs #7c3aed(经典对比) +- 蓝 vs 绿:#3b82f6 vs #10b981(性能对比) +- 橙 vs 蓝:#f97316 vs #3b82f6(冷暖对比) + +### 技巧2:确保数据准确性 + +**在提示词中嵌入精确数据**: + +``` +Create a bar chart with these EXACT values: +- Claude Sonnet 4: 850ms +- GPT-4 Turbo: 1100ms +- Gemini Pro: 950ms + +IMPORTANT: Use these exact numbers, do not approximate. +``` + +**生成后验证**: +- 目测检查数值 +- 如有误差,重新生成并强调精确性 + +### 技巧3:风格统一 + +**如果生成多张配图**: +- 使用相同的配色方案 +- 使用一致的字体风格 +- 保持相似的设计语言(扁平/3D、极简/丰富) + +**示例提示词统一元素**: +``` +Style consistency: +- Color palette: blue (#3b82f6), purple (#7c3aed), green (#10b981) +- Design: flat, modern, minimal +- Font: sans-serif, bold for titles +- Background: white with subtle gradient +``` + +### 技巧4:针对移动端优化 + +**考虑要素**: +- 文字大小:移动端阅读时文字要足够大 +- 对比度:确保在小屏幕上仍可辨识 +- 简化:移动端避免过于复杂的图表 + +**提示词调整**: +``` +Design for mobile viewing: +- Large, bold labels (minimum 14pt equivalent) +- High contrast colors +- Simple layout with clear spacing +- Maximum 4 data points for clarity +``` + +--- + +## 六、常见问题 + +### Q1:何时该生成2张内容配图,何时只生成1张? + +**答**:遵循"需求优先"原则: +- 如果文章有性能对比**和**架构说明,两者都很重要 → 生成2张 +- 如果只有一个复杂点需要图解 → 生成1张 +- 如果都是简单内容 → 0张 + +**经验法则**:如果你需要思考"要不要生成",那就不生成。 + +### Q2:生成的图表数据与文章不符怎么办? + +**答**: +1. 在提示词中用大写强调:`EXACT VALUES: A=85, B=90, C=78` +2. 重新生成2-3次,选择最准确的 +3. 如仍不准确,考虑用文字列表代替图表 + +### Q3:生成的架构图太复杂,看不清? + +**答**:简化策略: +- 减少层级(从4层减至3层) +- 合并同类组件(将多个微服务合并为"微服务集群") +- 去除次要连接线(只保留主要数据流) +- 分两张图展示(一张总览,一张局部放大) + +### Q4:如何判断配图是否真的有用? + +**自测**: +- 遮住图片,只读文字 → 是否能理解? + - 能理解 → 配图可能不必要 + - 难以理解 → 配图有价值 +- 给非专业人士看图 → 是否秒懂? + - 秒懂 → 好配图 + - 困惑 → 需要改进或删除 + +--- + +## 七、内容配图检查清单 + +### 生成前检查 +- [ ] 确认真的需要这张配图(不是装饰) +- [ ] 选择了合适的图表类型 +- [ ] 准备了准确的数据 +- [ ] 配色与封面图协调 + +### 生成后检查 +- [ ] 数据准确无误 +- [ ] 中文清晰可读 +- [ ] 视觉清晰不混乱 +- [ ] 文件大小合理(< 500KB) +- [ ] 文件命名规范 + +### 嵌入文章后检查 +- [ ] 位置紧跟相关段落 +- [ ] 有恰当的图注 +- [ ] 与文字内容呼应 +- [ ] 在移动端可读 + +--- + +## 八、最佳实践总结 + +### ✅ 应该做的 + +1. **少而精** - 0-2张配图,每张都有明确作用 +2. **数据准确** - 图表数据必须与文章一致 +3. **风格统一** - 配图与封面图配色协调 +4. **适时插入** - 紧跟相关文字段落 +5. **移动友好** - 确保小屏幕可读 + +### ❌ 不应该做的 + +1. **为了配图而配图** - 没有信息价值的装饰图 +2. **图表过于复杂** - 超过5个数据点或10个组件 +3. **风格杂乱** - 每张图配色、风格完全不同 +4. **数据错误** - 图表数值与文字不符 +5. **文件过大** - 单张图超过1MB + +### 📊 质量标准 + +**优秀内容配图**(满分10分): +- 信息价值:4分(传达了文字难以表达的信息) +- 准确性:3分(数据、标签完全准确) +- 清晰度:2分(视觉清晰、易读) +- 风格协调:1分(与整体风格一致) + +**及格线**:7分 +**优秀线**:9分 + +--- + +**记住**:内容配图不是必需的,但如果生成,必须有价值、准确、清晰! diff --git a/references/cover-image-guide.md b/references/cover-image-guide.md new file mode 100644 index 0000000..f528953 --- /dev/null +++ b/references/cover-image-guide.md @@ -0,0 +1,551 @@ +# 封面图生成详细指南 + +> **重要性**:封面图是文章打开率的关键因素,必须生成一张高质量、吸引眼球的主题封面图。 + +--- + +## 一、封面图设计原则 + +封面图的目的是**吸引读者点击**,必须遵循以下设计原则: + +### 1. 鲜明的主题色彩 + +根据文章类型选择合适的配色方案: + +| 文章类型 | 推荐配色 | 色彩代码 | 视觉效果 | +|---------|---------|---------|---------| +| **AI/科技类** | 蓝紫渐变 | #1a1f5c → #7c3aed | 未来感、科技感 | +| **工具/效率类** | 绿橙渐变 | #10b981 → #f97316 | 活力、高效 | +| **数据/分析类** | 蓝绿渐变 | #0891b2 → #06b6d4 | 专业、理性 | +| **创意/设计类** | 粉紫渐变 | #ec4899 → #a855f7 | 创新、灵动 | +| **企业/商业类** | 深蓝金色 | #1e3a8a → #f59e0b | 稳重、高端 | + +**色彩搭配技巧**: +- 使用渐变比纯色更有层次感 +- 避免超过3种主色 +- 确保文字与背景对比度足够(至少4.5:1) + +### 2. 清晰的视觉层次 + +**三层结构**: +1. **主标题**:大而醒目(中英文结合更有设计感) + - 字体:粗体、现代无衬线字体 + - 颜色:白色或高对比度颜色 + - 位置:**画面中央(垂直和水平居中)** + +2. **副标题**:简短精炼的中文说明(1句话概括核心价值) + - 字体:略小于主标题,优雅字体 + - 颜色:稍透明的白色(80-90%透明度) + - 位置:主标题下方 + +3. **视觉元素**:与主题相关的图标、插画或抽象图形 + - 3D立体元素优于平面图形 + - 有动感(箭头、粒子、光效) + - 不抢主标题的风头 + +**示例布局**: +``` +┌─────────────────────────────────────┐ +│ [渐变背景 + 粒子效果] │ +│ │ +│ [3D视觉元素:代码/AI/图表] │ +│ │ +│ 主标题(大、粗、白) │ +│ 副标题:核心价值说明 │ +│ 【居中显示,中央位置】 │ +│ │ +│ [装饰性光效] │ +└─────────────────────────────────────┘ +``` + +### 3. 现代化设计风格 + +**当前流行趋势**: +- ✅ 3D立体元素(球体、立方体、浮动面板) +- ✅ 玻璃拟态效果(半透明、模糊背景) +- ✅ 渐变光效(发光边缘、光束) +- ✅ 粒子系统(飘浮的点、星星) +- ✅ 简约留白(不拥挤,有呼吸感) + +**过时风格(避免)**: +- ❌ 扁平化纯色块 +- ❌ 拟物化写实风格 +- ❌ 过度装饰的花纹 +- ❌ 低分辨率位图 + +### 4. 情感共鸣 + +封面图要激发读者的情绪反应: + +| 目标情绪 | 视觉策略 | 文案方向 | 示例 | +|---------|---------|---------|------| +| **好奇** | 神秘光效、未知元素 | "你不知道的秘密" | AI能做到这一步了? | +| **兴奋** | 爆炸效果、上升箭头 | "改变工作方式" | 效率提升10倍 | +| **痛点** | 对比图、前后差异 | "告别重复劳动" | 从2小时到20分钟 | +| **启发** | 灯泡、思考元素 | "新视角" | 重新思考编程 | +| **价值** | 奖杯、勋章 | "从小白到专家" | 零基础上手 | + +### 5. 禁忌事项 + +❌ **不要做的事**: +- 纯文字堆砌,没有视觉设计 +- 颜色过于暗淡(灰色调)或刺眼(纯红、纯绿) +- 文字过多,信息过载(超过15个汉字) +- 与主题完全无关的装饰图(如随机的风景、人物) +- 使用低质量的素材(模糊、锯齿) +- 违反版权的品牌logo或图片 + +--- + +## 二、封面图提示词模板 + +根据文章类型选择合适的模板,然后定制化修改。 + +### 模板1:AI/大模型类 + +**适用场景**:介绍AI模型、机器学习工具、智能应用 + +``` +A stunning, eye-catching cover image for [主题名称] article. + +Design: vibrant gradient background from deep blue (#1a1f5c) to electric purple (#7c3aed), with glowing particles floating throughout and subtle light effects creating depth. + +Central visual elements (positioned behind text): +- 3D floating geometric cubes in glass morphism style, semi-transparent with frosted glass effect +- Each cube contains a glowing icon: code brackets symbol, AI brain circuit pattern, automation gear +- Cubes connected by luminous cyan (#06b6d4) energy lines creating a network visualization +- Soft particle system with small glowing dots scattered across the scene +- Light rays emanating from cubes with lens flare effects + +Text layout (CRITICAL - all text centered both horizontally and vertically): +- CENTER of image: Large bold title '[主题名称]' in white, modern sans-serif font with subtle glow +- Directly below title in CENTER: Chinese subtitle '[一句话价值说明]' in elegant font, slightly smaller, 90% opacity +IMPORTANT: All text must be centered in the MIDDLE of the image, not at top or bottom edges. + +Visual effects: +- Bokeh depth of field effect in background +- Subtle vignette darkening at edges +- Glowing highlights on cube edges +- Professional color grading with high contrast +- Clean composition with breathing space around text + +Style: ultra-modern, tech-forward, sci-fi inspired, professional, magazine-quality +Visual mood: innovative, powerful, intelligent, cutting-edge, transformative +Color palette: blue-purple gradient (#1a1f5c to #7c3aed) with cyan (#06b6d4) and white (#ffffff) accents + +CRITICAL REQUIREMENTS: +- All Chinese text in simplified Chinese (简体中文) +- Chinese characters must be clear, readable, and accurate - NO garbled text +- Text positioned in CENTER (middle) of image both horizontally and vertically +- High quality, 16:9 aspect ratio +- Professional design suitable for tech article cover +``` + +**变量替换**: +- `[主题名称]`:如"Claude Sonnet 4"、"GPT-5"、"Midjourney v7" +- `[一句话价值说明]`:如"超越人类的推理能力"、"让AI秒懂你的需求" + +**配色变体**: +- 深度学习主题:深蓝 → 青色 (#0f172a → #06b6d4) +- 创意AI主题:紫色 → 粉色 (#7c3aed → #ec4899) + +### 模板2:开发工具/框架类 + +**适用场景**:介绍编程框架、开发工具、技术栈 + +``` +A professional cover image for [工具名] tutorial article. +Design: clean gradient background from [主题色1] to [主题色2] with subtle code-related visual elements. +Background elements: 3D modular blocks or connected nodes representing the tool's architecture, with floating code snippets subtly integrated. +Text layout (CRITICAL - centered composition): +- CENTER (vertically and horizontally): main title "[工具名]" in bold, white font with slight shadow +- Directly below title (still in center area): subtitle "[核心价值说明]" in Chinese, elegant font +IMPORTANT: All text must be positioned in the CENTER of the image, both horizontally and vertically, NOT at top or sides. +Visual elements: terminal window frames, abstract code syntax highlighting, geometric shapes connected by lines around the centered text. +Style: developer-friendly, modern, clean, inspiring, minimal but not boring. +Visual mood: efficient, reliable, professional. +All text in simplified Chinese, clear and minimal. +16:9 aspect ratio, high resolution. +``` + +**示例填充**: +``` +[工具名] = "VSCode" +[核心价值说明] = "从代码编辑器到AI编程工作室" +[主题色1] = "#10b981" (绿色) +[主题色2] = "#f97316" (橙色) +``` + +**视觉元素选择**: +- 前端框架:组件拼图、响应式网格 +- 后端框架:服务器集群、API管道 +- 数据库工具:数据流动、表格结构 +- 测试工具:检查标记、流程图 + +### 模板3:效率/生产力类 + +**适用场景**:介绍提效工具、自动化方案、工作流优化 + +``` +An inspiring cover image for productivity article about [主题]. +Design: energetic gradient background (orange #f97316 to pink #ec4899, or green #10b981 to blue #3b82f6). +Background elements: upward arrow, rocket launching, or growth chart visualization in 3D, with dynamic motion effects subtly integrated. +Text layout (CRITICAL - centered composition): +- CENTER (vertically and horizontally): bold headline "[主题]" in large white font +- Directly below headline (still in center area): Chinese tagline "[提效价值,如:从2小时到20分钟]" with number highlighting +IMPORTANT: All text must be positioned in the CENTER of the image, both horizontally and vertically, NOT at top or bottom. +Visual elements: clock/timer symbols, speed lines, ascending graphs, productivity icons around the centered text. +Visual mood: energetic, optimistic, empowering, motivational. +Style: clean, modern, vibrant, action-oriented. +All text in simplified Chinese, bold and clear. +16:9 aspect ratio, professional quality. +``` + +**价值表达技巧**: +- 使用具体数字:"效率提升10倍"、"从2小时到20分钟" +- 使用对比:"告别手工操作"、"自动化一切" +- 使用动作词:"飞速提升"、"秒级完成" + +### 模板4:新闻/资讯类 + +**适用场景**:行业动态、技术新闻、产品发布 + +``` +A modern news cover image for [新闻主题]. +Design: bold gradient from dark [品牌色] to lighter shade, with geometric patterns and light streaks. +Background elements: 3D representation of the news topic (product, logo reimagined, or abstract symbol) subtly integrated, with breaking news effect. +Text layout (CRITICAL - centered composition): +- Small badge (above main title, center area): urgent tag "重磅" or "最新" +- CENTER (vertically and horizontally): main "[新闻标题]" in bold impactful font +- Directly below main title (still in center area): Chinese description "[关键信息]" +IMPORTANT: All main text must be positioned in the CENTER of the image, both horizontally and vertically, NOT at top or bottom edges. +Visual elements: alert icons, spotlight effects, geometric frames, modern tech aesthetics around the centered text. +Visual mood: urgent, important, timely, authoritative. +Style: news-worthy, professional, attention-grabbing. +All text in simplified Chinese, clear hierarchy. +16:9 aspect ratio. +``` + +**紧迫感营造**: +- 使用警示色:红色、橙色元素 +- 添加标签:"独家"、"重磅"、"突发" +- 使用放射状光线、聚光灯效果 + +### 模板5:教程/指南类 + +**适用场景**:技术教程、入门指南、实战案例 + +``` +A friendly tutorial cover image for [教程主题]. +Design: approachable gradient (soft blue to green, or warm orange to yellow), with guiding visual elements. +Background elements: step-by-step pathway visualization in 3D, or learning journey metaphor (stairs, roadmap) subtly integrated. +Text layout (CRITICAL - centered composition): +- CENTER (vertically and horizontally): main "[教程标题]" in friendly bold font +- Directly below main title (still in center area): subtitle "[目标受众/学习目标]" in Chinese, encouraging tone +IMPORTANT: All text must be positioned in the CENTER of the image, both horizontally and vertically, NOT at top or bottom. +Visual elements: checkmarks, progress indicators, friendly icons, guide arrows around the centered text. +Visual mood: encouraging, accessible, clear, supportive. +Style: approachable, modern, not intimidating, beginner-friendly. +All text in simplified Chinese, warm and inviting. +16:9 aspect ratio. +``` + +**亲和力营造**: +- 使用暖色系(橙黄、浅蓝、绿色) +- 添加进度指示器、步骤图标 +- 避免过于冷酷的科技感 + +--- + +## 三、生成封面图的执行步骤 + +### 步骤1:分析主题,确定封面图方向 + +**分析清单**: + +1. **提取主题关键词**(2-3个核心词) + - 示例:"VSCode更名" → 关键词:VSCode、AI、编辑器、转型 + +2. **概括核心价值**(一句话) + - 方法:用"让X可以Y"或"从X到Y"的句式 + - 示例:"从代码编辑器到氛围编程工作室" + +3. **确定目标情绪** + - 问自己:读者看到封面应该产生什么感受? + - 示例:好奇("VSCode改名了?")、兴奋("AI编程新时代") + +4. **选择文章类型** + - 对照上述5个模板,选择最匹配的 + +### 步骤2:选择配色方案 + +**决策树**: + +``` +是AI/智能相关? +├─ 是 → 蓝紫渐变 (#1a1f5c → #7c3aed) +└─ 否 → 继续判断 + ├─ 是开发工具? + │ └─ 是 → 绿橙渐变 (#10b981 → #f97316) + └─ 是效率/自动化? + └─ 是 → 橙粉渐变 (#f97316 → #ec4899) +``` + +**配色验证**: +- 在白色文字下,背景是否足够深? +- 渐变是否自然(不生硬)? +- 是否符合主题气质? + +### 步骤3:构建提示词 + +**组装步骤**: + +1. **选择模板**(从上述5个模板中选择) + +2. **填充变量**: + - 替换 `[主题]` 为实际主题 + - 填入核心价值的中文表述 + - 选择合适的配色代码 + - 选择合适的视觉元素 + +3. **强化中文文字要求**: + - 必须包含:`text in simplified Chinese, minimal text, accurate` + - 重申一次:`All Chinese characters must be clear and correct` + +4. **添加质量关键词**: + - high quality, professional design + - 16:9 aspect ratio + - modern, eye-catching + +**示例(完整提示词)**: +``` +A stunning cover image for VSCode AI transformation article. +Design: gradient background from deep blue (#1a1f5c) to vibrant purple (#7c3aed) with glowing particles and light effects. +Center: modern 3D elements representing code editor transforming into AI assistant, with floating code snippets, neural network nodes, and sparkles. +Text layout: +- Top center: bold title "VSCode × AI" in white, modern sans-serif font +- Below: Chinese subtitle "从代码编辑器到氛围编程工作室" in elegant font, slightly smaller +Visual elements: VSCode-style interface fragments, AI brain/circuit patterns, transformation arrows with glow effect. +Style: modern, tech-forward, innovative, eye-catching with depth and dimension. +Visual mood: transformative, intelligent, cutting-edge, exciting. +All text in simplified Chinese where applicable, minimal and impactful. +All Chinese characters must be clear and correct. +16:9 aspect ratio, high quality, professional design. +``` + +### 步骤4:调用API生成 + +**使用generate_image.py脚本**: + +```bash +cd /root/.claude/skills/wechat-tech-writer + +python scripts/generate_image.py \ + --prompt "你构建的完整提示词" \ + --api gemini \ + --output "输出路径/cover.png" +``` + +**API选择建议**: +- **首选Gemini**:质量高,中文支持好,速度快 +- **备选DALL-E**:质量稳定,但中文可能有乱码 + +**常见参数**: +```bash +--api gemini # 使用Gemini API(推荐) +--api dalle # 使用DALL-E API +--quality hd # 高清质量(仅DALL-E) +--size 1792x1024 # 16:9尺寸(仅DALL-E) +--proxy http://... # 设置代理(如需要) +``` + +**错误处理**: +- API密钥未配置 → 检查环境变量 `GEMINI_API_KEY` +- 生成失败 → 简化提示词,减少复杂要求 +- 中文乱码 → 强化提示词中的中文要求,或换API + +### 步骤5:验证封面图质量 + +**质量检查清单**: + +✅ **文字检查**: +- [ ] 中文文字清晰可读,无乱码 +- [ ] 文字数量适中(不超过15个汉字) +- [ ] 文字与背景对比度足够 + +✅ **颜色检查**: +- [ ] 配色鲜明,吸引眼球 +- [ ] 渐变自然,无生硬过渡 +- [ ] 整体色调符合主题 + +✅ **视觉检查**: +- [ ] 视觉重点突出(标题最醒目) +- [ ] 层次清晰(主标题 > 副标题 > 视觉元素) +- [ ] 不拥挤,有留白 + +✅ **主题检查**: +- [ ] 视觉元素与主题相关 +- [ ] 传达的情绪符合预期 +- [ ] 能激发读者点击欲望 + +**不满意时的调整策略**: + +| 问题 | 调整方案 | +|------|---------| +| 文字模糊/乱码 | 强化提示词:"large, clear Chinese characters";或换API | +| 颜色暗淡 | 提高对比度:"vibrant colors, high contrast" | +| 视觉元素太多 | 简化提示词:"minimal design, clean composition" | +| 与主题不符 | 明确视觉元素:"code editor interface, NOT generic tech" | +| 布局混乱 | 强调层次:"clear hierarchy, title at top center" | + +**迭代策略**: +- 第1次:按模板生成 +- 第2次:基于问题微调提示词 +- 第3次:大幅调整(换模板或换API) + +**保存最佳版本**: +```bash +# 生成多个版本 +python scripts/generate_image.py --prompt "..." --output cover_v1.png +python scripts/generate_image.py --prompt "..." --output cover_v2.png +python scripts/generate_image.py --prompt "..." --output cover_v3.png + +# 选择最佳版本重命名 +cp cover_v2.png cover.png +``` + +--- + +## 四、高级技巧 + +### 技巧1:利用负面提示(Negative Prompts) + +部分API支持负面提示,告诉AI不要生成什么: + +``` +Negative prompt: blurry text, messy layout, too many colors, generic stock photos, outdated design, flat 2D style +``` + +### 技巧2:参考知名品牌风格 + +可以参考(但不抄袭)知名科技品牌的设计风格: + +- **Apple风格**:极简、留白、优雅字体 +- **Google风格**:多彩、几何、友好 +- **Microsoft风格**:流畅设计、亚克力效果、现代 +- **Tech媒体风格**(如The Verge):大胆配色、强对比、视觉冲击 + +**提示词示例**: +``` +Style: inspired by modern tech media like The Verge, bold colors and clean typography +``` + +### 技巧3:使用情绪板(Mood Board) + +在提示词中明确情绪参考: + +``` +Visual mood: like launching a rocket (exciting), discovering a secret (mysterious), solving a puzzle (satisfying) +``` + +### 技巧4:分层生成(适用于复杂封面) + +对于特别复杂的封面,可以分两次生成后合成: + +1. 生成背景层(渐变 + 粒子效果) +2. 生成前景层(3D元素 + 文字) +3. 使用图像编辑工具合成 + +**注意**:大多数情况下一次生成即可,除非有特殊要求。 + +--- + +## 五、常见问题排查 + +### Q1:生成的封面图文字全是英文,没有中文? + +**原因**:提示词中中文要求不够强调 + +**解决**: +1. 在提示词多处强调中文: + ``` + Text layout: + - Top: "[中文标题]" in CHINESE CHARACTERS + - Below: Chinese subtitle "[中文副标题]" in simplified Chinese + + IMPORTANT: All text must be in simplified Chinese (简体中文), clear and readable. + ``` + +2. 如果仍然失败,换用DALL-E API + +### Q2:封面图颜色与预期不符? + +**原因**:色彩代码未被准确识别 + +**解决**: +- 使用颜色名称替代代码:`deep blue to vibrant purple` 而非 `#1a1f5c to #7c3aed` +- 添加颜色描述:`gradient from midnight blue (dark, professional) to electric purple (vibrant, modern)` + +### Q3:封面图太"抽象",看不出主题? + +**原因**:视觉元素描述不够具体 + +**解决**: +- 明确具体物体: + ``` + ❌ "tech elements" + ✅ "code editor window with syntax highlighting, AI neural network nodes, transformation arrows" + ``` + +### Q4:生成速度很慢或超时? + +**原因**:提示词过于复杂,或API服务器繁忙 + +**解决**: +- 简化提示词,删除次要细节 +- 增加timeout参数:`--timeout 180` +- 换个时间段重试 + +### Q5:封面图质量不够高清? + +**原因**:API默认设置或压缩 + +**解决**: +- DALL-E使用:`--quality hd --size 1792x1024` +- Gemini已默认高质量,无需额外设置 +- 生成后检查文件大小,应 > 200KB + +--- + +## 六、封面图最佳实践总结 + +### ✅ 应该做的 + +1. **强制生成封面图** - 每篇文章必须有 +2. **选择合适配色** - 根据主题选择模板 +3. **强调中文要求** - 在提示词多处声明 +4. **验证质量** - 用清单检查 +5. **保存到正确位置** - 与文章在同一目录 + +### ❌ 不应该做的 + +1. **不要跳过封面图** - 即使时间紧也要生成 +2. **不要使用无关图片** - 必须与主题契合 +3. **不要过度装饰** - 保持简洁有力 +4. **不要忽视文字质量** - 中文必须清晰 +5. **不要使用低质量图片** - 分辨率和清晰度很重要 + +### 📊 质量标准 + +**优秀封面图的标准**(满分10分): +- 视觉吸引力:3分(色彩鲜明、设计现代) +- 主题契合度:3分(一看就知道讲什么) +- 文字清晰度:2分(中文无乱码、易读) +- 情感共鸣:2分(激发点击欲望) + +**及格线**:7分(可以使用) +**优秀线**:9分(直接使用) + +--- + +**记住**:封面图是读者对文章的第一印象,值得花时间打磨! diff --git a/references/fact-checking.md b/references/fact-checking.md new file mode 100644 index 0000000..2f1ddc7 --- /dev/null +++ b/references/fact-checking.md @@ -0,0 +1,307 @@ +# 事实核查指南 + +## 为什么事实准确性至关重要 + +在技术科普文章中,事实错误会: +- 损害作者的专业信誉 +- 误导读者 +- 造成传播错误信息 +- 影响读者的技术决策 + +**核心原则**:宁可保守,不要夸大;宁可不说,不要说错。 + +## 必须核查的信息类型 + +### 1. 产品/工具的基本信息 + +**需要核查**: +- ✅ 产品的全称和简称 +- ✅ 开发公司/团队 +- ✅ 发布时间 +- ✅ 最新版本号 +- ✅ 官方网站URL +- ✅ GitHub仓库地址(如适用) + +**核查方法**: +- 访问官方网站确认 +- 查看GitHub仓库的README +- 检查多个来源的信息一致性 + +**常见错误示例**: +❌ "OpenAI的Claude模型..."(错误:Claude是Anthropic的) +❌ "LangChain由Google开发"(错误:是独立开源项目) + +### 2. 技术参数和性能数据 + +**需要核查**: +- ✅ 模型参数量 +- ✅ 上下文窗口大小 +- ✅ 处理速度/性能指标 +- ✅ 支持的语言/格式 +- ✅ 价格/收费模式 + +**核查方法**: +- 查阅官方文档 +- 参考官方发布的Benchmark +- 如果不同来源数据不一致,采用官方数据 + +**表述建议**: +✅ "根据官方文档,Claude Sonnet 4支持200K token的上下文窗口" +✅ "在官方Benchmark测试中,性能提升约30%" +⚠️ 避免:使用未经证实的"传闻"数据 + +### 3. 功能特性 + +**需要核查**: +- ✅ 产品确实具备所述功能 +- ✅ 功能的具体实现方式 +- ✅ 功能的限制条件 + +**核查方法**: +- 查看官方功能列表 +- 阅读产品文档 +- 如可能,实际测试验证 + +**常见陷阱**: +❌ 将"路线图中的功能"当作"已实现的功能" +❌ 夸大功能效果 +❌ 忽略重要的使用限制 + +### 4. 对比和排名 + +**需要核查**: +- ✅ 对比的维度是否公平 +- ✅ 数据来源是否可靠 +- ✅ 测试条件是否一致 + +**安全表述**: +✅ "在某某评测中,XX排名第一"(指明评测来源) +✅ "根据GitHub Star数,XX是同类工具中最受欢迎的之一" +⚠️ 避免:主观的"最好"、"最强"等绝对化表述 + +### 5. 技术原理 + +**需要核查**: +- ✅ 技术术语使用正确 +- ✅ 原理解释符合实际 +- ✅ 避免过度简化导致错误 + +**处理建议**: +- 对于复杂原理,用类比时要注明"简单来说" +- 不确定的原理细节可以略过,重点讲应用 +- 引用权威解释而非臆测 + +### 6. 时间相关信息 + +**需要核查**: +- ✅ 发布时间 +- ✅ 更新时间 +- ✅ "最新"、"最近"等时效性表述 + +**注意事项**: +- 明确标注时间点 +- 避免使用可能过时的"最新"表述 +- 如信息可能变化,加上"截至XX时间" + +## 核查流程 + +### 步骤1:抓取阶段的初步核查 + +在抓取文章内容后: + +1. **识别关键事实**:标记所有涉及数字、名称、时间的信息 +2. **交叉验证**:对比多个来源的同一信息 +3. **优先级排序**:官方来源 > 权威媒体 > 技术博客 > 社交媒体 + +### 步骤2:改写阶段的再次核查 + +在改写文章时: + +1. **每个数据都确认来源**:确保不是凭记忆或猜测 +2. **谨慎处理二手信息**:如果只有一个来源,需要特别谨慎 +3. **避免推断性表述**:除非有明确依据 + +### 步骤3:输出前的最后检查 + +文章完成后,逐项检查: + +- [ ] 产品名称、公司名称拼写正确 +- [ ] 所有数字都有来源支撑 +- [ ] 技术术语使用准确 +- [ ] 没有夸大或误导性表述 +- [ ] 对比数据公平且有依据 +- [ ] 时间信息准确且有时效性说明 + +## 信息可靠性分级 + +### 高可靠性来源(优先使用) + +1. **官方来源** + - 官方网站 + - 官方文档 + - 官方博客 + - GitHub官方仓库 + +2. **权威技术媒体** + - TechCrunch、The Verge等知名科技媒体 + - IEEE、ACM等学术机构 + - 大型科技公司的技术博客 + +### 中等可靠性来源(需交叉验证) + +1. **技术博客和社区** + - Medium、Dev.to + - 掘金、CSDN(选择高质量文章) + - Stack Overflow + +2. **行业分析报告** + - Gartner、IDC等 + - 独立测评机构 + +### 低可靠性来源(谨慎使用) + +1. **社交媒体** + - Twitter、Reddit + - 微信公众号(非官方) + - 用户评论 + +2. **匿名或来源不明的内容** + +## 不确定时的处理策略 + +### 策略1:保守表述 + +**不确定时**: +❌ "Claude Sonnet 4的参数量达到1000亿" +✅ "据报道,Claude Sonnet 4是一个大规模语言模型"(不提具体数字) + +### 策略2:明确来源 + +**表述模式**: +- "根据官方文档..." +- "在XX评测中..." +- "开发团队表示..." +- "据多个来源报道..." + +### 策略3:使用限定词 + +**限定词库**: +- 约、大约、估计 +- 之一(避免"最") +- 声称、据称 +- 可能、通常 +- 在某些情况下 + +**示例**: +✅ "被认为是最受欢迎的AI工具之一" +✅ "在某些任务上性能提升约30%" + +### 策略4:省略细节 + +当无法确认细节时,省略比猜测更好: + +❌ "该工具使用了xxx算法"(不确定) +✅ "该工具通过先进的算法实现了xxx功能"(只讲结果) + +## 常见事实错误类型 + +### 错误1:混淆产品和公司 + +❌ "OpenAI的Claude模型" +✅ "Anthropic的Claude模型" + +### 错误2:数据过时 + +❌ "GPT-4是最新的OpenAI模型"(可能已过时) +✅ "截至2024年X月,GPT-4是OpenAI的主流模型之一" + +### 错误3:以偏概全 + +❌ "AI都会产生幻觉" +✅ "大语言模型可能产生不准确的输出,这被称为'幻觉'" + +### 错误4:因果关系错误 + +❌ "因为使用了Transformer,所以性能最好" +✅ "采用了Transformer架构,在某些任务上表现出色" + +### 错误5:绝对化表述 + +❌ "完全解决了xx问题" +✅ "在很大程度上改善了xx问题" + +## 高风险信息清单 + +以下信息务必多次核查: + +🔴 **极高风险**(错了影响很大): +- 公司名称、产品名称 +- 价格、收费模式 +- 开源协议类型 +- 安全性相关声明 +- 法律法规相关内容 + +🟡 **中高风险**(容易出错): +- 技术参数(上下文长度、参数量等) +- 性能数据和Benchmark结果 +- 发布时间、版本号 +- 支持的功能特性 + +🟢 **低风险**(影响相对较小): +- 使用体验描述 +- 应用场景举例 +- 行业趋势判断 + +## 事实核查工具和方法 + +### 快速核查技巧 + +1. **搜索多个关键词变体** + - 产品全称 + 简称 + - 中文名 + 英文名 + - 加上 "官方"、"official" 等关键词 + +2. **查看多个来源** + - 至少对比2-3个独立来源 + - 官方信息优先 + +3. **检查时间戳** + - 确认信息发布时间 + - 优先使用最新信息 + +4. **验证链接有效性** + - 确保官网、GitHub链接可访问 + - 避免引用已失效的链接 + +## 输出时的标注建议 + +为了保持透明度,在适当位置标注: + +**数据来源标注**: +```markdown +> 数据来源:官方文档(截至2024年12月) +``` + +**不确定性标注**: +```markdown +注:关于XX的具体参数,官方未公开详细信息,以上为根据公开资料的合理推测。 +``` + +**时效性提醒**: +```markdown +*本文信息截至2024年12月,产品功能可能随版本更新而变化,请以官方最新信息为准。* +``` + +## 最后的自我提问 + +完成文章后,问自己: + +1. 我能为文章中的每个关键事实指出来源吗? +2. 如果读者质疑某个数据,我能提供证据吗? +3. 有没有使用"最好"、"最强"等无法证实的表述? +4. 文章中的技术术语使用准确吗? +5. 有没有把未来计划当作现有功能? +6. 对比和评价是否公平客观? +7. 所有链接都能正常访问吗? + +如果有任何一项回答"不确定",就需要重新核查或修改表述。 diff --git a/references/image-guidelines.md b/references/image-guidelines.md new file mode 100644 index 0000000..fee9663 --- /dev/null +++ b/references/image-guidelines.md @@ -0,0 +1,280 @@ +# 图片选择与处理指南 + +> **说明**:本文档主要讲解如何从抓取的文章中提取和选择真实图片。关于AI生成图片的详细指南,请参考 `ai-image-generation.md`。 + +## 图片获取的双轨策略 + +技术文章配图应该采用**真实截图 + AI生成**的混合策略: + +### 真实图片(优先) +- ✅ 产品实际界面截图 +- ✅ GitHub仓库页面 +- ✅ 官方架构图和流程图 +- ✅ 真实的数据图表 + +**本文档内容** - 如何提取这些真实图片 + +### AI生成图片(补充) +- ✅ 封面图/首图 +- ✅ 概念示意图 +- ✅ 场景插画 +- ✅ 装饰性配图 + +**参考文档** - `references/ai-image-generation.md` + +--- + +## 图片在公众号文章中的作用 + +好的配图可以: +- 增强视觉吸引力 +- 帮助理解复杂概念 +- 打破大段文字,提升阅读体验 +- 提供具体的产品/功能展示 + +## 图片数量建议 + +**文章长度与图片数量对应**: +- 1000-1500字:3-4张图片 +- 1500-2500字:4-6张图片 +- 2500-4000字:6-8张图片 + +**分布原则**: +- 每2-3个段落后配一张图 +- 避免连续多段文字无图 +- 文章开头最好有一张吸引眼球的图 + +## 优先选择的图片类型 + +### 1. 产品截图(最优先) + +**适用场景**:介绍工具、平台、应用 + +**选择标准**: +- 界面清晰,文字可读 +- 展示核心功能 +- 尺寸适中(不要太小) + +**示例**: +- AI对话界面的截图 +- 代码编辑器的界面 +- 工具的操作面板 + +### 2. 架构图/流程图 + +**适用场景**:解释技术原理、工作流程 + +**选择标准**: +- 图示清晰,逻辑明确 +- 不要过于复杂(元素不超过10个) +- 中文标注优先,英文也可接受 + +**示例**: +- 系统架构图 +- 数据流向图 +- 使用流程示意图 + +### 3. 对比图表 + +**适用场景**:功能对比、性能对比 + +**选择标准**: +- 数据来源可靠 +- 对比维度清晰 +- 视觉对比明显 + +**示例**: +- 不同模型的性能对比柱状图 +- 功能特性对比表 +- 使用场景对比 + +### 4. 示例展示 + +**适用场景**:展示实际应用效果 + +**选择标准**: +- 效果直观 +- 与文章内容紧密相关 + +**示例**: +- AI生成的代码示例 +- 工具处理前后的对比 +- 实际应用案例截图 + +### 5. Logo和品牌图 + +**适用场景**:文章开头或介绍产品时 + +**选择标准**: +- 官方高清Logo +- 背景简洁 + +## 不推荐的图片类型 + +❌ **纯文字图片** +- 除非是特别有设计感的标题图 +- 文字内容应该用正文表达 + +❌ **模糊或分辨率过低的图片** +- 影响专业度 +- 手机端显示效果差 + +❌ **与内容无关的配图** +- 不要为了凑数而用无关图片 +- 会分散读者注意力 + +❌ **过于复杂的技术图** +- 密密麻麻的代码截图 +- 超过20个元素的复杂架构图 +- 普通用户看不懂的底层原理图 + +❌ **侵权风险高的图片** +- 带有明显水印的图片 +- 商业图库的未授权图片 + +## 从抓取文章中提取图片 + +### 提取策略 + +1. **浏览抓取的文章内容**,识别包含``标签或Markdown图片语法的部分 + +2. **提取图片URL**,格式通常为: + - `` + - `![alt text](https://...png)` + +3. **评估图片质量**: + - 检查URL是否有效(不是placeholder或broken link) + - 判断图片类型是否符合上述"优先选择"标准 + - 避免提取广告图、无关配图 + +4. **记录图片信息**: + - 图片URL + - 图片说明(如果原文有) + - 建议插入位置(文章的哪个部分) + +### 提取示例 + +**从HTML内容提取**: +```html +Claude对话界面 +``` +提取为: +- URL: https://example.com/claude-interface.png +- 说明: Claude对话界面 +- 建议位置: "功能介绍"部分 + +**从Markdown内容提取**: +```markdown +![LangChain架构图](https://example.com/langchain-arch.png) +``` +提取为: +- URL: https://example.com/langchain-arch.png +- 说明: LangChain架构图 +- 建议位置: "技术原理"部分 + +## 图片在文章中的呈现方式 + +### 在Markdown中标注图片 + +使用标准Markdown语法 + 说明: + +```markdown +## 核心功能 + +Claude Sonnet 4的对话界面非常简洁直观: + +![图1:Claude Sonnet 4对话界面](图片URL或占位符) +*Claude的对话界面,支持长文本输入和多轮对话* + +如上图所示,你可以... +``` + +### 图片说明文字(Caption) + +每张图片都应该有简短说明: + +**格式**:`*说明文字*`(斜体) + +**内容**: +- 10-20字最佳 +- 点明图片展示的内容 +- 与正文呼应 + +**示例**: +- *图1:Claude Sonnet 4的主界面* +- *GPT-4与Claude在代码生成任务上的性能对比* +- *LangChain的核心组件架构* + +## 输出格式 + +在文章末尾单独列出所有图片信息,方便用户下载: + +```markdown +--- + +## 文章配图列表 + +1. **封面图/首图** + - 图片URL: https://... + - 说明: XXX产品Logo或主视觉图 + - 建议位置: 文章开头 + +2. **图1:产品界面** + - 图片URL: https://... + - 说明: XXX的操作界面截图 + - 建议位置: "核心功能"部分 + +3. **图2:架构图** + - 图片URL: https://... + - 说明: XXX的技术架构示意图 + - 建议位置: "技术原理"部分 + +... (以此类推) + +**注意**:请检查图片链接是否有效,如失效请用相似图片替换。 +``` + +## 无法获取图片时的处理 + +如果抓取的文章中没有合适的图片,或图片链接失效: + +1. **在文章中标注图片位置** +```markdown +[此处建议插入:Claude Sonnet 4的对话界面截图] +``` + +2. **在图片列表中说明** +```markdown +## 文章配图建议 + +由于原文图片不可用,建议补充以下配图: + +1. **产品Logo或官网截图** + - 建议来源: 访问官网 https://... + - 建议位置: 文章开头 + +2. **功能演示截图** + - 建议来源: 使用产品并截图,或搜索相关图片 + - 建议位置: "核心功能"部分 +``` + +3. **提供图片搜索建议** +```markdown +推荐图片搜索关键词: +- "Claude Sonnet 4 interface" +- "LangChain architecture diagram" +- "GitHub项目名称 screenshot" +``` + +## 图片质量检查清单 + +输出前检查: + +- [ ] 每张图片都有URL和说明 +- [ ] 图片与内容相关性强 +- [ ] 避免了纯文字图片(除非特殊设计) +- [ ] 图片数量适中(3-6张) +- [ ] 图片分布均匀,不过于集中 +- [ ] 优先选择了产品截图、架构图等高价值图片 +- [ ] 所有图片URL已整理到列表中 +- [ ] 如有无法获取的图片,已给出替代建议 diff --git a/references/writing-style.md b/references/writing-style.md new file mode 100644 index 0000000..61799f9 --- /dev/null +++ b/references/writing-style.md @@ -0,0 +1,228 @@ +# 微信公众号写作风格指南 + +## ⚠️ 重要优化原则(2025-12-27更新) + +### 1. 文章结构简化 +- **只输出正文内容**,不要添加任何附加部分 +- ❌ **禁止添加**: + - "参考资料与延伸阅读"章节 + - "关于优缺点的说明"章节 + - "文章配图说明"章节 + - "本文信息来源"等元信息 + - 任何其他非正文内容 +- ✅ **只保留**: + - 文章标题 + - 正文各章节 + - 文章结尾总结段落 + +### 2. 链接格式规范 +- **所有URL必须使用纯文本格式**,不使用markdown超链接 +- ❌ 错误格式:`[小米官网](https://www.xiaomi.com/)` +- ✅ 正确格式:`小米官网:https://www.xiaomi.com/` +- 如果文中需要提及链接,直接写: + ``` + 官方网站:https://www.example.com/ + GitHub仓库:https://github.com/user/repo + API文档:https://api.example.com/docs + ``` + +### 3. 配图精简原则 +- 每篇文章图片数量:**1-3张**(不再是4-6张) +- 只生成真正必要的图片: + - 有数据对比 → 生成对比图 + - 有复杂技术 → 生成架构图 + - 可选封面图 +- 不生成装饰性配图和场景插画 + +## 核心原则 + +### 1. 为普通用户写作 + +**目标读者**:对技术感兴趣但不一定有深厚技术背景的普通用户 + +**实践方法**: +- 避免未解释的技术术语 +- 使用类比和比喻帮助理解 +- 先解释"是什么"和"为什么",再讲"怎么做" + +**示例对比**: + +❌ 不好的写法: +> "Claude采用了Transformer架构,通过自注意力机制实现上下文理解,支持200K token的上下文窗口。" + +✅ 好的写法: +> "Claude就像一个记忆力超强的助手,可以一次性记住相当于一本小说的内容(约15万字),并在对话中准确引用这些信息。它通过一种叫做Transformer的技术来理解你说的话,就像我们人类在对话时会根据上下文理解意思一样。" + +### 2. 用自己的语言改写 + +**绝对禁止**: +- 直接复制粘贴原文段落 +- 仅改几个词就当作改写 +- 保留原文的句式结构 + +**改写技巧**: +- 理解核心观点后,用自己的话重新表达 +- 重新组织信息顺序 +- 增加自己的解释和例子 +- 改变句式和段落结构 + +**示例**: + +原文: +> "LangChain是一个用于开发由大型语言模型驱动的应用程序的框架。它提供了一系列工具、组件和接口,简化了创建由LLM驱动和链接的应用程序的过程。" + +❌ 差的改写(仅换词): +> "LangChain是一个用于开发大语言模型应用的框架。它提供了工具、组件和接口,让创建LLM应用变得更简单。" + +✅ 好的改写(重新表达): +> "想象你要用AI搭建一个应用,但发现需要把很多功能拼凑在一起——比如让AI记住对话历史、查询数据库、调用第三方API等。LangChain就是为了解决这个问题而生的。它就像搭积木的工具箱,把这些常用功能都封装好了,你只需要按需组合,就能快速搭建出AI应用。" + +### 3. 增加可读性 + +**段落控制**: +- 每段2-4句话 +- 避免超过5行的长段落 +- 重要观点单独成段 + +**句子长度**: +- 多用短句(15-20字) +- 复杂概念拆成多个简单句 +- 避免一句话超过40字 + +**列表使用**: +适当使用项目符号或数字列表,便于快速浏览: +- 功能特性列举 +- 步骤说明 +- 对比要点 + +### 4. 增强互动感 + +**人称使用**: +- 多用"你"、"我们" +- 避免"用户"、"读者"等疏离词汇 +- 创造对话感 + +**提问引导**: +在适当位置使用反问,引发思考: +- "你是否也遇到过这样的问题?" +- "那么,它到底是怎么做到的呢?" + +**情感词汇**: +适当使用情感词汇增加感染力: +- "令人惊讶的是..." +- "更厉害的是..." +- "这个功能特别实用..." + +## 文章结构模板 + +### 标题 + +**公式**:{吸引注意} + {核心关键词} + +**示例**: +- "Claude Sonnet 4来了!这个AI助手能帮你做什么?" +- "开发者必看:LangChain让AI应用开发效率提升10倍" +- "GitHub上爆火的XXX工具,5分钟带你上手" + +### 开头段(钩子) + +用100-200字吸引读者,可以采用: + +**方式1:场景引入** +> "你有没有遇到过这样的情况:想让AI帮你写代码,但它总是'忘记'你前面说过的需求?或者聊了几轮之后,它就'失忆'了?今天要介绍的Claude Sonnet 4,就彻底解决了这个痛点。" + +**方式2:问题引入** +> "大语言模型很强大,但如果你想让它查询数据库、调用API、记住对话历史,该怎么办?一个个手写代码显然太麻烦。这就是为什么LangChain会成为AI开发者的'必装工具'。" + +**方式3:数据/事实引入** +> "GitHub上一个新工具刚发布两周,Star数就突破了5000。它能做什么?简单说,它让部署AI应用从几小时缩短到几分钟。" + +### 主体内容 + +按照SKILL.md中推荐的结构展开: +1. 是什么 +2. 能做什么 +3. 为什么选择它 +4. 如何开始 + +每部分都要有: +- 小标题(用emoji增加视觉吸引力) +- 2-3个段落 +- 至少1个具体例子 +- 适当的图片(如果有) + +### 结尾 + +**总结要点**(2-3句话) +**行动号召**(1句话) + +**示例**: +> "总的来说,Claude Sonnet 4在长文本理解、代码生成和多轮对话方面都有明显提升。如果你正在寻找一个靠谱的AI助手,不妨试试看。 +> +> 文末附上了官方文档和使用教程,感兴趣的朋友可以自己探索更多功能。" + +## 语言风格细节 + +### Emoji使用建议 + +**适度使用**(每篇3-5个): +- 小标题前:📌、💡、🎯、✨、🚀 +- 强调重点:⚡、🔥、💪、👍 +- 总结部分:📝、🎁、🌟 + +**避免过度**: +不要每句话都加emoji,会显得不专业 + +### 比喻和类比库 + +**抽象概念具象化**: +- API → "插座和电器的关系" +- 框架 → "搭积木的工具箱" +- 上下文窗口 → "记忆容量" +- Token → "字数单位" +- 训练数据 → "教材" + +### 常用技术词汇的通俗解释 + +| 技术词汇 | 通俗解释 | +|---------|---------| +| 大语言模型(LLM) | AI对话助手、智能助手 | +| 提示词(Prompt) | 给AI的指令、问AI的问题 | +| 微调(Fine-tuning) | 针对性训练、专项优化 | +| API | 程序之间的"对话接口" | +| 开源 | 代码公开、免费使用 | +| Star(GitHub) | 点赞、收藏 | +| Fork | 复制一份来改造 | +| Token | AI理解的文本单位(类似字数) | + +## 质量自检 + +改写完成后,问自己: + +1. ✅ 如果我是完全不懂技术的人,能看懂这篇文章吗? +2. ✅ 有没有哪个段落直接照搬了原文? +3. ✅ 技术术语都解释清楚了吗? +4. ✅ 有没有具体的例子和应用场景? +5. ✅ 读起来是"听人讲解"还是"看说明书"?(应该像前者) +6. ✅ 标题能吸引目标读者点开吗? +7. ✅ 文章有明确的结构和逻辑吗? + +## 避免的常见错误 + +❌ **错误1:堆砌功能列表** +不要只是列出"功能1、功能2、功能3...",而要解释每个功能解决什么问题。 + +❌ **错误2:过度技术化** +"采用分布式架构,通过负载均衡实现高并发处理" → 这对普通用户没有意义 + +✅ **改进**: +"即使同时有成千上万人使用,也不会卡顿" + +❌ **错误3:缺乏具体例子** +只说"功能强大"、"性能优秀",不如给一个具体场景。 + +❌ **错误4:结构混乱** +想到哪写到哪,读者看不出重点。 + +❌ **错误5:过度营销化** +"史上最强"、"秒杀一切"这类词汇要避免,保持客观。 diff --git a/scripts/__pycache__/generate_image.cpython-312.pyc b/scripts/__pycache__/generate_image.cpython-312.pyc new file mode 100644 index 0000000..f595257 Binary files /dev/null and b/scripts/__pycache__/generate_image.cpython-312.pyc differ diff --git a/scripts/generate_cover_optimized.py b/scripts/generate_cover_optimized.py new file mode 100644 index 0000000..7a28c1b --- /dev/null +++ b/scripts/generate_cover_optimized.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""按照优化后的设计原则生成封面图""" +import sys +import os + +sys.path.insert(0, os.path.dirname(__file__)) +from generate_image import GeminiImageGenerator + +def generate_optimized_cover(): + """ + 按照新的设计原则生成Claude Skills封面图 + + 设计原则: + 1. 鲜明的主题色彩 - 蓝紫渐变 (科技创新类) + 2. 清晰的视觉层次 - 主标题 + 副标题 + 视觉元素 + 3. 现代化设计风格 - 3D元素、玻璃拟态、渐变光效 + 4. 情感共鸣 - "告别重复劳动"、"秒变专家" + """ + + # 步骤1: 主题分析 + # 关键词: Claude Skills, AI提效, 技能包, 专家系统 + # 核心价值: 让AI秒变领域专家 + # 目标情绪: 好奇、兴奋、启发 + + # 步骤2: 配色方案 + # 科技创新类: 蓝紫渐变 (#1a1f5c → #7c3aed) + + # 步骤3: 构建提示词(使用AI/大模型类模板) + prompt = """A stunning, eye-catching cover image for Claude Skills article. + +Design specifications: +- Background: vibrant gradient from deep blue (#1a1f5c) to electric purple (#7c3aed), with subtle particle effects and glowing accents +- Center focal point: futuristic 3D floating cubes/modules in glass morphism style, representing different skills +- Each cube has a glowing icon inside: document (文档), code brackets (代码), chart (数据) +- Cubes are connected by luminous blue energy lines, creating a network effect +- Depth and dimension: strong 3D perspective with light reflections + +Text layout (CRITICAL - all text in simplified Chinese): +- Top center: Large bold title "Claude Skills" in white, modern sans-serif font +- Below title: Chinese subtitle "让AI秒变领域专家" in elegant, clean font +- Bottom left corner: Small text "告别重复劳动 | 10倍提效" as a tagline + +Visual effects: +- Glowing particles floating in the background +- Soft light rays emanating from the cubes +- Professional depth of field (bokeh effect) +- Clean, uncluttered composition with proper whitespace + +Style: ultra-modern, tech-forward, professional, highly attractive, sci-fi inspired +Mood: innovative, powerful, exciting, transformative +Color harmony: blue-purple gradient with cyan and white accents + +IMPORTANT: All text in simplified Chinese (简体中文), minimal text, accurate and clear. +Aspect ratio: 16:9, high quality, magazine cover style. +""" + + output_path = r"G:\git_pull\微信公众号文章\AI提效系列\claude_skills_cover_optimized.png" + + try: + print("Generating optimized cover image with enhanced design principles...") + print("Theme: Claude Skills - AI Capability Extension System") + print("Core value: Turn AI into domain experts instantly") + print("Color scheme: Blue-purple gradient (tech innovation)") + print("Emotional appeal: Curiosity, excitement, empowerment") + print("") + + generator = GeminiImageGenerator() + result = generator.generate(prompt, output_path) + + print(f"Success: {result}") + print("") + print("Quality checklist:") + print("- Clear and readable Chinese text") + print("- Eye-catching colors") + print("- Strong visual hierarchy") + print("- Aligned with theme") + + return 0 + except Exception as e: + print(f"Error: {str(e)}") + return 1 + +if __name__ == "__main__": + sys.exit(generate_optimized_cover()) diff --git a/scripts/generate_image.py b/scripts/generate_image.py new file mode 100644 index 0000000..8fe9e1e --- /dev/null +++ b/scripts/generate_image.py @@ -0,0 +1,419 @@ +#!/usr/bin/env python3 +""" +图片生成API调用脚本 + +支持多种图片生成API: +- Gemini Imagen API (Google) +- DALL-E API (OpenAI) +- 其他自定义API + +使用方法: + python generate_image.py --prompt "图片描述" --api gemini --output output.png + python generate_image.py --prompt "图片描述" --api dalle --output output.png +""" + +import os +import sys +import argparse +import base64 +import requests +from pathlib import Path +from typing import Optional, Dict, Any + + +class ImageGenerator: + """图片生成器基类""" + + def __init__(self, api_key: Optional[str] = None): + self.api_key = api_key or self._get_api_key() + + def _get_api_key(self) -> str: + """从环境变量获取API密钥""" + raise NotImplementedError + + def _get_proxies(self, proxy: Optional[str] = None) -> Optional[Dict[str, str]]: + """获取代理配置""" + # 优先使用命令行参数指定的代理 + if proxy: + return { + 'http': proxy, + 'https': proxy + } + + # 其次从环境变量读取 + http_proxy = os.environ.get('HTTP_PROXY') or os.environ.get('http_proxy') + https_proxy = os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy') + + if http_proxy or https_proxy: + return { + 'http': http_proxy or https_proxy, + 'https': https_proxy or http_proxy + } + + return None + + def generate(self, prompt: str, output_path: str, **kwargs) -> str: + """生成图片并保存""" + raise NotImplementedError + + +class GeminiImageGenerator(ImageGenerator): + """Gemini Imagen API图片生成器 - 使用 Google Genai SDK""" + + def _get_api_key(self) -> str: + api_key = os.environ.get('GEMINI_API_KEY') or os.environ.get('GOOGLE_API_KEY') + if not api_key: + raise ValueError("请设置环境变量 GEMINI_API_KEY 或 GOOGLE_API_KEY") + return api_key + + def generate(self, prompt: str, output_path: str, **kwargs) -> str: + """ + 使用 Google Genai SDK 生成图片 + + 参考: https://ai.google.dev/gemini-api/docs/image-generation + """ + try: + from google import genai + except ImportError: + raise ImportError("请先安装 google-genai SDK: pip install google-genai") + + try: + # 创建客户端 - 环境变量中的代理会被自动使用 + client = genai.Client(api_key=self.api_key) + + # 使用图片生成模型 + model = kwargs.get("model", "gemini-3-pro-image-preview") + + # 生成图片 + response = client.models.generate_content( + model=model, + contents=[prompt], + ) + + # 处理响应并保存图片 + for part in response.parts: + if part.inline_data is not None: + # 获取图片对象 + image = part.as_image() + # 保存图片 + image.save(output_path) + return output_path + + raise ValueError("API 响应中未找到图片数据") + + except Exception as e: + raise RuntimeError(f"Gemini API调用失败: {str(e)}") + + +class DALLEImageGenerator(ImageGenerator): + """DALL-E API图片生成器 (OpenAI)""" + + def _get_api_key(self) -> str: + api_key = os.environ.get('OPENAI_API_KEY') + if not api_key: + raise ValueError("请设置环境变量 OPENAI_API_KEY") + return api_key + + def generate(self, prompt: str, output_path: str, **kwargs) -> str: + """ + 使用DALL-E API生成图片 + + 参考: https://platform.openai.com/docs/api-reference/images + """ + url = "https://api.openai.com/v1/images/generations" + + headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {self.api_key}" + } + + # DALL-E 3参数 + data = { + "model": kwargs.get("model", "dall-e-3"), + "prompt": prompt, + "n": 1, + "size": kwargs.get("size", "1792x1024"), # 16:9比例 + "quality": kwargs.get("quality", "standard"), # standard 或 hd + "response_format": "b64_json" # 返回base64编码 + } + + # 配置代理 + proxies = self._get_proxies(kwargs.get("proxy")) + + try: + response = requests.post(url, json=data, headers=headers, proxies=proxies, timeout=120) + response.raise_for_status() + + result = response.json() + + # 提取图片数据 + if "data" in result and len(result["data"]) > 0: + image_data = result["data"][0].get("b64_json") + if image_data: + # 解码并保存图片 + image_bytes = base64.b64decode(image_data) + with open(output_path, 'wb') as f: + f.write(image_bytes) + return output_path + + raise ValueError(f"API返回数据格式异常: {result}") + + except requests.exceptions.RequestException as e: + raise RuntimeError(f"DALL-E API调用失败: {str(e)}") + + +class AnthropicImageGenerator(ImageGenerator): + """Anthropic原生图片生成(通过Claude调用)""" + + def _get_api_key(self) -> str: + # Claude环境下不需要单独的API key + return "not_required" + + def generate(self, prompt: str, output_path: str, **kwargs) -> str: + """ + 使用Claude的原生图片生成能力 + + 注: 这个方法在claude.ai环境中可用 + """ + # 在claude.ai环境中,可以直接生成图片 + # 这里返回提示信息,实际生成由调用方处理 + return f"请使用Claude原生能力生成图片: {prompt}" + + +class DoubaoImageGenerator(ImageGenerator): + """豆包即梦(火山引擎)图片生成器""" + + # 火山引擎图片生成API端点(正确路径) + BASE_URL = "https://ark.cn-beijing.volces.com/api/v3" + IMAGES_ENDPOINT = "/images/generations" + + # 可用的图片生成模型 + IMAGE_MODELS = { + "seedream-5-0": "doubao-seedream-5-0-260128", + "seedream-4-5": "doubao-seedream-4-5-251128", + "seedream-4-0": "doubao-seedream-4-0-250828", + "seedream-3-0": "doubao-seedream-3-0-t2i-250415", + } + + def _get_api_key(self) -> str: + api_key = os.environ.get('ARK_API_KEY') or os.environ.get('DOUBAO_API_KEY') + if not api_key: + raise ValueError("请设置环境变量 ARK_API_KEY 或 DOUBAO_API_KEY") + return api_key + + def _validate_size(self, size: str) -> str: + """验证并调整图片尺寸(至少需要 3686400 像素)""" + if not size: + return "2048x2048" + + if "x" in size: + try: + w, h = map(int, size.split("x")) + pixels = w * h + if pixels < 3686400: + print(f"⚠️ 尺寸 {size} 像素不足,已自动调整为 2048x2048") + return "2048x2048" + except: + pass + return size + + def generate(self, prompt: str, output_path: str, **kwargs) -> str: + """ + 使用火山引擎 Seedream 图片生成API + + 参考: https://www.volcengine.com/docs/82379/1541523 + + 模型选项: + - seedream-5-0: Seedream 5.0 (默认) + - seedream-4-5: Seedream 4.5 + - seedream-4-0: Seedream 4.0 + - seedream-3-0: Seedream 3.0 + + 尺寸要求: 至少 3686400 像素(约 1920x1920) + """ + model_name = kwargs.get("model", "seedream-5-0") + model_id = self.IMAGE_MODELS.get(model_name, model_name) + + # 正确的 API 端点 + url = f"{self.BASE_URL}{self.IMAGES_ENDPOINT}" + + headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {self.api_key}" + } + + # 验证尺寸 + size = self._validate_size(kwargs.get("size", "2048x2048")) + + data = { + "model": model_id, + "prompt": prompt, + "size": size, + "output_format": kwargs.get("format", "png"), + "response_format": "url", + "watermark": kwargs.get("watermark", False) + } + + proxies = self._get_proxies(kwargs.get("proxy")) + + try: + print(f"🎨 使用火山引擎 {model_name} ({model_id}) 生成图片...") + print(f"📐 尺寸: {size}") + + response = requests.post(url, json=data, headers=headers, proxies=proxies, timeout=180) + + if response.status_code != 200: + print(f"响应状态: {response.status_code}") + print(f"响应内容: {response.text[:500]}") + + response.raise_for_status() + result = response.json() + + if "error" in result: + raise RuntimeError(f"API错误: {result['error']}") + + if "data" in result and len(result["data"]) > 0: + image_url = result["data"][0].get("url") + + if image_url: + print("📥 下载图片中...") + img_response = requests.get(image_url, proxies=proxies, timeout=60) + img_response.raise_for_status() + + with open(output_path, 'wb') as f: + f.write(img_response.content) + return output_path + + raise ValueError(f"API返回数据格式异常: {result}") + + except requests.exceptions.RequestException as e: + raise RuntimeError(f"火山引擎API调用失败: {str(e)}") + except Exception as e: + raise RuntimeError(f"图片生成失败: {str(e)}") + + +# API映射 +API_GENERATORS = { + "gemini": GeminiImageGenerator, + "imagen": GeminiImageGenerator, # 别名 + "dalle": DALLEImageGenerator, + "openai": DALLEImageGenerator, # 别名 + "anthropic": AnthropicImageGenerator, + "claude": AnthropicImageGenerator, # 别名 + "doubao": DoubaoImageGenerator, # 豆包即梦/火山引擎 + "volcengine": DoubaoImageGenerator, # 别名 + "seedream": DoubaoImageGenerator, # 别名 +} + + +def main(): + parser = argparse.ArgumentParser( + description="调用生图API生成图片", + formatter_class=argparse.RawDescriptionHelpFormatter + ) + + parser.add_argument( + "--prompt", + required=True, + help="图片生成提示词" + ) + + parser.add_argument( + "--api", + choices=list(API_GENERATORS.keys()), + default="gemini", + help="使用的API (默认: gemini). 支持: gemini, dalle, doubao(豆包即梦/火山引擎)" + ) + + parser.add_argument( + "--output", + required=True, + help="输出图片路径" + ) + + parser.add_argument( + "--aspect-ratio", + default="16:9", + help="图片宽高比 (默认: 16:9)" + ) + + parser.add_argument( + "--size", + help="图片尺寸 (DALL-E专用, 如: 1792x1024)" + ) + + parser.add_argument( + "--quality", + choices=["standard", "hd"], + default="standard", + help="图片质量 (DALL-E专用)" + ) + + parser.add_argument( + "--proxy", + help="代理地址 (如: http://127.0.0.1:7890 或 socks5://127.0.0.1:1080)" + ) + + parser.add_argument( + "--model", + help="图片生成模型 (豆包: seedream-5-0, seedream-4-5, seedream-3-0)" + ) + + args = parser.parse_args() + + # 创建输出目录 + output_path = Path(args.output) + output_path.parent.mkdir(parents=True, exist_ok=True) + + # 获取生成器类 + generator_class = API_GENERATORS[args.api] + + try: + # 创建生成器实例 + generator = generator_class() + + # 准备参数 + kwargs = { + "aspect_ratio": args.aspect_ratio, + } + + # 添加代理配置 + if args.proxy: + kwargs["proxy"] = args.proxy + + if args.api in ["dalle", "openai"]: + if args.size: + kwargs["size"] = args.size + kwargs["quality"] = args.quality + + # 豆包/火山引擎模型参数 + if args.api in ["doubao", "volcengine", "seedream"]: + if args.model: + kwargs["model"] = args.model + if args.size: + kwargs["size"] = args.size + + # 生成图片 + print(f"🎨 使用 {args.api.upper()} API生成图片...") + print(f"📝 提示词: {args.prompt}") + + result_path = generator.generate( + prompt=args.prompt, + output_path=str(output_path), + **kwargs + ) + + if args.api in ["anthropic", "claude"]: + print(f"ℹ️ {result_path}") + return 1 + + print(f"✅ 图片已生成: {result_path}") + return 0 + + except Exception as e: + print(f"❌ 生成失败: {str(e)}", file=sys.stderr) + return 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/generate_temp.py b/scripts/generate_temp.py new file mode 100644 index 0000000..9d69620 --- /dev/null +++ b/scripts/generate_temp.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""临时图片生成脚本,避免emoji输出问题""" +import sys +import os + +# 添加脚本目录到路径 +sys.path.insert(0, os.path.dirname(__file__)) + +from generate_image import GeminiImageGenerator + +def generate_cover(): + """生成封面图""" + prompt = """A modern, professional cover image for Claude Skills technology article. +Design features a gradient background from deep blue (#1a1f5c) to purple (#7c3aed). +In center, floating modular 3D blocks representing different skills, each block labeled in simplified Chinese: +'文档处理' (Document Processing), '代码审查' (Code Review), '数据分析' (Data Analysis). +Blocks are connected by glowing blue lines suggesting interconnectivity. +At the top, large bold text 'Claude Skills' with Chinese subtitle '让AI秒变领域专家' (Turn AI into Domain Experts). +Style: minimalist, tech-forward, professional, clean. +All text in simplified Chinese, minimal text, clear and accurate. +16:9 aspect ratio, high quality.""" + + output_path = r"G:\git_pull\微信公众号文章\AI提效系列\claude_skills_cover.png" + + try: + print("Generating cover image...") + generator = GeminiImageGenerator() + result = generator.generate(prompt, output_path) + print(f"Success: {result}") + return 0 + except Exception as e: + print(f"Error: {str(e)}") + return 1 + +def generate_architecture(): + """生成架构图""" + prompt = """A technical architecture diagram illustrating the three-layer loading mechanism of Claude Skills. +The diagram shows three horizontal layers stacked vertically with distinct colors: +- Top layer in light blue (#60a5fa) labeled '元数据层 ~100词' (Metadata Layer ~100 words) +- Middle layer in medium blue (#3b82f6) labeled '核心指令层 <5k词' (Core Instruction Layer <5k words) +- Bottom layer in dark blue (#1e40af) labeled '资源层 无限制' (Resource Layer Unlimited) +On the right side, arrows show progressive loading from top to bottom with text '按需加载' (Load on Demand). +On the left, simple icons represent each layer: lightbulb for metadata, gear for instructions, database for resources. +Style: clean, professional technical diagram, minimal design, data visualization style. +All text in simplified Chinese, minimal and accurate text. +16:9 aspect ratio, high quality.""" + + output_path = r"G:\git_pull\微信公众号文章\AI提效系列\claude_skills_architecture.png" + + try: + print("Generating architecture diagram...") + generator = GeminiImageGenerator() + result = generator.generate(prompt, output_path) + print(f"Success: {result}") + return 0 + except Exception as e: + print(f"Error: {str(e)}") + return 1 + +if __name__ == "__main__": + if len(sys.argv) > 1 and sys.argv[1] == "architecture": + sys.exit(generate_architecture()) + else: + sys.exit(generate_cover()) diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh new file mode 100755 index 0000000..a097f53 --- /dev/null +++ b/scripts/install_dependencies.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# wechat-tech-writer 技能依赖安装脚本 +# 用于读取 Word/PDF 文档并生成技术文章 + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +echo "📦 正在安装 wechat-tech-writer 技能依赖..." + +# 检查并安装 Homebrew 依赖 +install_brew_package() { + local pkg=$1 + if ! brew list "$pkg" &>/dev/null; then + echo " ➜ 安装 $pkg..." + brew install "$pkg" + else + echo " ✅ $pkg 已安装" + fi +} + +# 安装 pandoc (Word 文档读取) +install_brew_package "pandoc" + +# 安装 poppler (PDF 文本提取,包含 pdftotext) +install_brew_package "poppler" + +# 安装 python-docx (备选方案,用于复杂 Word 文档) +if ! python3 -c "import docx" 2>/dev/null; then + echo " ➜ 安装 python-docx..." + pip3 install python-docx +else + echo " ✅ python-docx 已安装" +fi + +# 安装 pdfplumber (备选方案,用于保留 PDF 结构) +if ! python3 -c "import pdfplumber" 2>/dev/null; then + echo " ➜ 安装 pdfplumber..." + pip3 install pdfplumber +else + echo " ✅ pdfplumber 已安装" +fi + +echo "" +echo "✅ 所有依赖安装完成!" +echo "" +echo "可用功能:" +echo " - pandoc: 读取 .docx Word 文档" +echo " - pdftotext: 读取 .pdf PDF 文档" +echo " - python-docx: 复杂 Word 文档备选方案" +echo " - pdfplumber: PDF 结构保留备选方案" diff --git a/scripts/test_generated_image.png b/scripts/test_generated_image.png new file mode 100644 index 0000000..e7084db Binary files /dev/null and b/scripts/test_generated_image.png differ