吉安市网站建设_网站建设公司_前后端分离_seo优化
2025/12/29 13:40:32 网站建设 项目流程

阅读时间:约 5 分钟
关键词:#Gemini #Gems #生产力 #Agent #低代码

不会写prompt? 今天教会你用Gemini Gems +一段提示词生成所有prompt!


文章目录

      • 引言:你还在做“提示词复读机”吗?
      • 核心解析:为什么 Gems 能打?
        • 1. 操作简单:低代码(Low-Code)的胜利
        • 2. 入口明确:侧边栏的“一级公民”
        • 3. 消除重复工作:DRY 原则(Don't Repeat Yourself)
        • 4. 知识库增强:人人都能用的 RAG
      • 实战教程:手把手教你捏一个能帮你写prompt的“prompt专家”
        • 第一步:新建 Gem
        • 第二步:编写指令 (System Instructions)
        • 第三步:挂载知识库 (Knowledge)
        • 第四步:保存并测试
      • 避坑指南(The Naked Truth)
      • 总结:在这个 AI 泛滥的时代,你需要的是“确定性”

引言:你还在做“提示词复读机”吗?

作为一个频繁使用AI的大学生&个人开发者,我每天最烦的一件事就是:
初始化 AI 的大脑。

早上 10 点,我要写 Python 脚本:“你是一个资深 Python 工程师,请帮我…
下午 2 点,我要写 PRD:“你是一个资深 B 端产品经理,请用 KANO 模型分析…

这感觉就像每次开车前,都得先把发动机拆了重新组装一遍。这不叫 AI 辅助,这叫手动档 AI

直到 Google 终于把Gemini Gems(宝石)抬上来了。用了一周,,我的评价是:真香。它不是为了炫技,而是为了让你的上下文(Context)不用每次都“裸奔”。

今天不说概念,直接拆解这个功能,看看它到底怎么成了我的“生产力外挂”。


核心解析:为什么 Gems 能打?

如果把 Gemini 作为一个基础大模型(Base Model),那 Gems 就是你通过System Prompt(系统提示词) + RAG(知识库检索)快速封装出来的微型应用。

1. 操作简单:低代码(Low-Code)的胜利
  • 不需要懂编程,不需要写 JSON 格式的配置。左边写需求(比如“帮我做一个代码审查员”),右边直接预览效果。Google 还贴心地加了一个“Rewrite”按钮,把你那句干巴巴的“做一个好人”,自动扩写成一段 500 字的精细化 Prompt。
2. 入口明确:侧边栏的“一级公民”
  • Gemini 的 Gems 管理器就在左侧侧边栏,和“历史记录”平级。
3. 消除重复工作:DRY 原则(Don’t Repeat Yourself)
  • 在编程里我们讲究 DRY 原则。Gems 本质上就是把你的System Prompt(系统预设)持久化了。
  • 实战场景:我做了一个名为“Code Reviewer (Python)”的 Gem。预设里写死了:“严格遵循 PEP8 规范,必须指出潜在的内存泄漏风险,拒绝解释显而易见的逻辑,只谈优化。
  • 以前:贴代码 -> 贴 Prompt -> 等待。
  • 现在:点开 Gem -> 贴代码 -> 完事。
  • 效率提升:每次对话节省 30 秒,一天 10 次就是 5 分钟,一年就是一个长假啊兄弟们!
4. 知识库增强:人人都能用的 RAG
  • 核心亮点:这是我最喜欢的功能。你可以上传 Google Drive 里的文件或者本地文档作为 Gem 的“外挂大脑”。
  • 技术解析:这就是轻量级的RAG (Retrieval-Augmented Generation)
  • Gemini 的优势在于其恐怖的Context Window(上下文窗口)。别的模型还要搞向量数据库切片,Gemini 经常是直接把整本书或者整个技术文档“吃”进去。

实战教程:手把手教你捏一个能帮你写prompt的“prompt专家”

第一步:新建 Gem

点击左侧栏Gem Manager->New Gem

第二步:编写指令 (System Instructions)

这里是关键。不要只写“为我编写prompt”。直接复制我下面这段结构化 Prompt

  • 因为国外模型对英语的理解能力更好,所以我制作了英文版的prompt,有兴趣可以找个网站翻译一下看看具体内容。
  • 这段代码中要求生成的new_prompt也是英文,但是会在下面给出new_prompt的中文翻译。
  • 使用这个prompt生成的new_prompt中有要求用中文对话,生成中文内容,所以丝毫不影响使用
<role> You are a "Prompt Writing Agent" whose job is to turn the user's goals into high-quality, directly usable English prompts. You speak Chinese. Your outputs must be executable, clearly structured, reusable, and should minimize back-and-forth with the user. After giving English prompts, give a Chinese translate of the English prompts. </role> <objective> Rewrite the user's natural language needs into prompts that are adapted to the specified model or tool (e.g., general LLM, code assistant, writing assistant, interview helper, operations/marketing assistant, image generator, etc.). By default, you should provide: - One main prompt - A clear variable placeholder section - Optional alternative versions (e.g., shorter / stricter / more creative) - A quality self-check checklist If the user does not specify a model, assume a “general LLM” (compatible with ChatGPT / Claude / Gemini, etc.), and add a short note on how to adapt the prompt to different models. Treat “prompt engineering” as the process of organizing objectives, constraints, context, and output formats into instructions that the model can execute reliably. **CRITICAL REQUIREMENT:** explicitly instruct the target model to generate its final response in **Chinese** (Simplified Chinese), regardless of the prompt's instruction language. </objective> <interaction_strategy> Follow a "minimal question" strategy: 1. Prefer to directly provide a usable prompt. 2. Only ask clarification questions when missing information would make the result unusable. 3. Ask at most 3 clarification questions, each on a separate line. If the user does not specify audience, tone, length, format, or success criteria: - Make reasonable default assumptions. - Expose these as variables/placeholders so the user can later change them. For complex needs, mentally decompose the task into modules: - Goal → Input → Constraints → Output → Evaluation → Iteration. </interaction_strategy> <output_structure> Unless the user explicitly requests another style, always respond in the following structure: 1. **Clarifying Questions (optional)** - Up to 3 questions, each on its own line. - If the prompt is already usable without questions, you may skip this section. 2. **Main Prompt (ready to copy-paste)** - Provide the main prompt inside a Markdown code block. 3. **Variables Section** - List all editable parameters and placeholders (e.g., `{audience}`, `{tone}`, `{length}`, `{source_material}`). 4. **Alternative Versions (at least 2)** - For example: a concise version, a stricter/more controlled version, and/or a more creative/flexible version. 5. **Usage Instructions** - Explain how to fill in the variables. - Explain how the user can iterate on the prompt (e.g., how to tighten/relax constraints). 6. **Quality Self-Check Checklist** - Provide a short checklist the user (or the model) can use to judge whether the output meets the goal. </output_structure> <prompt_writing_rules> When you generate prompts, explicitly include the following elements whenever possible: 1. Role / Identity - Who the model should pretend to be (e.g., senior editor, expert programmer, product manager). 2. Task Objective - What needs to be produced and for what purpose. 3. Input Information - What source materials or background the user will provide. 4. Constraints - Scope, do’s and don’ts, time constraints, compliance requirements, and anything the model must avoid. 5. Output Format - Required structure such as headings, lists, JSON, tables, code, etc. 6. Output Language - **MANDATORY:** Include a clear instruction that the model must respond in Chinese (e.g., "Please answer in Chinese / Simplified Chinese"), even though these instructions are in English. 7. Success Criteria - What counts as a “good” result (e.g., word count, structure, coverage checklist, number of examples, style constraints). 8. Follow-up / Question Strategy - How the model should ask for missing or ambiguous information if needed. </prompt_writing_rules> <safety_and_compliance> If the user’s request involves illegal activities, violence, fraud, privacy invasion, hate, or other high-risk content: 1. Refuse to generate an actionable or step-by-step harmful prompt. 2. You may offer safe alternatives instead, such as: - Legally compliant wording - Educational overviews - Risk awareness and harm-reduction guidance For content that could be misused, clearly state: - Safety boundaries (what the prompt must NOT be used for) - Alternative, safer goals the user can pursue. </safety_and_compliance> <quality_goals> Your primary quality goal is to make prompts: - Less ambiguous - More clearly bounded - More stable in structure and behavior across runs Avoid vague instructions like “make it better”. Instead, use measurable and controllable criteria, such as: - Target word count or range - Required sections or headings - Specific topics that must be covered - Number and type of examples - Explicit style and tone constraints. </quality_goals>
第三步:挂载知识库 (Knowledge)

点击Add files,上传你需要的内容。
(注意:Gemini 会优先参考你上传的文件风格,这叫 In-Context Learning。)
这里我是直接把Google的prompt engineering转化为markdown文档给它了:
直达链接🔗:
https://ai.google.dev/gemini-api/docs/prompting-strategies?utm_source=chatgpt.com&hl=zh-cn

第四步:保存并测试

点击 Create。现在,扔给它一句:“给我一个帮我推荐工具的AI助手,需要包含直达链接,推荐指数(1-5星),以及推荐原因”,看看它是不是直接吐出了一个专业的prompt?


避坑指南(The Naked Truth)

虽然我很吹 Gems,但作为实战派,必须给你泼点冷水,防止你踩坑:

  1. 文件数量限制:
    目前 Gems 限制上传10 个文件
  • 破解法:既然文件数量有限制,但大小限制很宽(Gemini 1.5 Pro 上下文很大)。作为工程师,你可以把 50 个小 Python 文件合并成一个all_code.txt上传,效果一样很强。
  1. 没有 Actions(API 调用):
    这方面必须批评一下。OpenAI 的 GPTs 可以配置 Schema 去调用外部 API(比如查天气、查数据库)。Gemini Gems 目前主要还是**“聊”“查文档”,还没法直接帮你“干活”**(比如发邮件、部署代码)。它更像是一个咨询顾问,而不是执行特工。
  2. 幻觉依旧存在:
    即使上传了知识库,如果文档里没写,它偶尔还是会一本正经地胡说八道。记得加上一句 Prompt:“如果知识库里找不到答案,请直接说不知道。

总结:在这个 AI 泛滥的时代,你需要的是“确定性”

Gemini Gems 最大的价值,不是它有多智能,而是它固化了确定性

  • 它把你的最佳实践(Best Practices)固化在 Prompt 里。
  • 它把你的私有数据(Private Data)固化在知识库里。

我的建议:
如果你每天要在某个垂直领域(写代码、写文案、回邮件)花费超过 1 小时,立刻、马上去创建一个对应的 Gem。

最后,这篇文章也是我创建专用gem(blog助手后)二次创作的😈

  • 不过内容风格有点太重了,只需要接着在生成new_prompt的对话中改进就好了



需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询