Skip to content
The Chat Archive
o3-2025-04-16· OpenAI LMArena Human Preference 140K

请帮忙设计一个prompt 工程体系,帮忙细化完善上述功能,对不同的网站类型,设计风格,页面结构设计不同的prompt来组合使用

  1. User

    请帮忙设计一个prompt 工程体系,帮忙细化完善上述功能,对不同的网站类型,设计风格,页面结构设计不同的prompt来组合使用

  2. Assistant

    🔧 一套可组合的 Prompt 工程体系

    目标:让 DeepSeek 在不同「网站类型 × 设计风格 × 页面结构」的场景下,都能稳定地产生高质量前端原型代码。


    1️⃣ 架构总览

    System Prompt      👉 角色定位 & 硬性规则(永远存在)
    ├── Meta Prompt    👉 输出格式 / 代码风格 / 约束
    └── Slot Prompts   👉 可以自由组合的模块
          ├─ Website-Type Slot(网站类型)
          ├─ Design-Style Slot(设计风格)
          ├─ Page-Structure Slot(页面结构)
          ├─ Function Slot(功能模块)
          └─ Extra Slot(可选:多语言 / SEO / 无障碍…)
    

    组合公式(伪码)

    Final Prompt =
      [System Prompt] 
      + [Meta Prompt]
      + concat(
            Website-Type Slot,
            Design-Style Slot,
            Page-Structure Slot,
            Function Slot,
            Extra Slot…
        )
    

    2️⃣ System Prompt(一次性配置)

    You are "DeepSeek-WebProto", an expert web-prototype generator.
    Always:
    1. Output valid, runnable HTML/CSS/JS **inside code fences**.
    2. Use semantic HTML5, mobile-first, WCAG-AA.
    3. Comment in Simplified Chinese.
    4. Reply nothing except the code & brief explanation section titles.
    

    3️⃣ Meta Prompt(所有场景共用)

    # 输出层级
    第一部分:<EXPLANATION> — 用 200 字以内概述实现要点  
    第二部分:<CODE> —— 使用 markdown code fence,按目录组织:
          /index.html
          /styles.css
          /app.js
    第三部分:<NEXT_STEP> —— 提示可选交互或改进
    
    # 代码规范
    - 采用 Flexbox + CSS 变量
    - 不引入外部框架(除非 Function Slot 要求)
    - ≤ 2 秒 CLS 0.1以内
    

    4️⃣ Slot Prompt 库

    下面给出 3 组核心 Slot,每组一个 关键词 ➜ Prompt 模板。
    实际调用时只需把所选关键词对应模板拼接即可。

    4.1 Website-Type Slot

    关键词Prompt 片段
    corporate“本网站是【企业官网】,强调品牌形象与服务介绍,需包含:巨幅横幅、核心优势区块、客户案例、联系表单。”
    ecommerce“本网站是【电商平台】,含:产品网格、筛选/搜索、购物车侧边栏、结算页占位。”
    blog“本网站是【技术博客】,含:文章列表、标签云、作者信息卡片、评论占位。”
    portfolio“本网站是【个人作品集】,含:项目画廊、关于我、技能条、可下载简历按钮。”
    saas“本网站是【SaaS Landing】,含:价值主张区、分段定价表、客户 Logo、CTA 按钮。”

    4.2 Design-Style Slot

    关键词Prompt 片段
    modern“设计风格:【现代极简】,大留白,主色 #0A84FF,辅色 #F2F5F8,圆角 8px,San-serif 字体。”
    professional“设计风格:【商务专业】,深蓝+灰色调,配衬线体,强调可信度与稳定感。”
    creative“设计风格:【活泼创意】,使用渐变、斜切背景,色彩大胆(#FF6B6B / #FFE66D)。”
    dark“设计风格:【暗黑模式】,深灰背景(#121212),文本#E0E0E0,UI 高对比。”
    retro“设计风格:【复古卡片】,浅米色底,打字机字体,加粗边框阴影。”

    4.3 Page-Structure Slot

    关键词Prompt 片段
    single“页面结构:【单页应用】,通过锚点导航;顶部固定 navbar,滚动动画。”
    multi“页面结构:【多页】,需生成:index.html, about.html, contact.html 三页及共用 header/footer。”
    dashboard“页面结构:【仪表盘】,侧边栏导航 + 主内容区域,包含折线图 / 饼图占位 div。”
    pwa“页面结构:【PWA】,含 manifest.json 与 Service Worker 基本骨架。”

    5️⃣ Function Slot(可按需多选)

    • auth: “加入登录/注册模态框(仅前端占位)。”
    • search: “提供实时搜索框(前端假数据过滤)。”
    • form: “联系表单需含:姓名、邮箱、信息;表单验证。”
    • animation: “使用 scroll-reveal 动效,IntersectionObserver 实现。”
    • i18n: “结构预留多语言切换按钮(中/英)。”

    6️⃣ Extra Slot(可选)

    • seo: “在 <head> 中加入基本 SEO meta、OpenGraph。”
    • a11y: “为交互元素添加适当 aria-* 属性。”

    7️⃣ 组合与调用示例

    需求:我要一个“电商平台 + 现代极简 + 多页 + 搜索&购物车 + SEO”的原型。

    拼接顺序(伪代码)

    final_prompt = (
        SYSTEM_PROMPT +
        META_PROMPT +
        WEBSITE_SLOT['ecommerce'] +
        DESIGN_SLOT['modern'] +
        PAGE_SLOT['multi'] +
        FUNCTION_SLOT['search'] +
        FUNCTION_SLOT['auth'] +    # 也可以继续加
        EXTRA_SLOT['seo']
    )
    response = deepseek_api(final_prompt)
    

    生成的完整 prompt(片段示意)👇

    You are "DeepSeek-WebProto", an expert web-prototype generator...
    # 输出层级
    第一部分...
    ---
    本网站是【电商平台】...
    设计风格:【现代极简】...
    页面结构:【多页】...
    提供实时搜索框(前端假数据过滤)。
    在 <head> 中加入基本 SEO meta、OpenGraph。
    

    8️⃣ 代码实现:Prompt 生成器

    class PromptFactory:
        def __init__(self):
            from collections import defaultdict
            self.system = SYSTEM_PROMPT
            self.meta = META_PROMPT
            self.slots = defaultdict(dict)
            self.slots['website'] = WEBSITE_SLOT
            self.slots['style'] = DESIGN_SLOT
            self.slots['page'] = PAGE_SLOT
            self.slots['func'] = FUNCTION_SLOT
            self.slots['extra'] = EXTRA_SLOT
    
        def build(self, website, style, page, funcs=None, extras=None):
            prompt = [
                self.system,
                self.meta,
                self.slots['website'][website],
                self.slots['style'][style],
                self.slots['page'][page]
            ]
            for f in (funcs or []):
                prompt.append(self.slots['func'][f])
            for e in (extras or []):
                prompt.append(self.slots['extra'][e])
            return "\n".join(prompt)
    

    9️⃣ 迭代 & 提升思路

    1. 动态 few-shot:把历史“好结果”作为示例追加到 Meta Prompt,提高一致性。
    2. Token Budget:超长需求时,把 Function Slot 放到单独 functions 调用,或分两次请求。
    3. 评分-重试:用正则 & AST 检测返回代码;不达标时自动重写。
    4. 用户反馈注入:把“用户评价 ➜ Refine Slot”追加到下一轮 prompt,实现循环优化。

    ✅ 小结

    通过「System + Meta + Slot 模块化」方案,你可以像搭积木一样,把网站类型、设计风格、页面结构、功能需求灵活拼接成稳定的高级 Prompt,使 DeepSeek 每次都能按照预期输出现成的前端原型。祝你构建愉快,🚀 若还有细节想深入,随时呼叫!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.