解决方案评测|告别复杂配置!基于阿里云云原生应用开发平台CAP快速部署Bolt.diy

简介: 本文介绍了基于阿里云CAP平台快速部署Bolt.diy的全流程。Bolt.new是一款强大的无代码对话网站构建工具,其开源版本Bolt.diy虽功能强大但部署复杂。阿里云的新解决方案简化了这一过程,通过函数计算(FC)和通义千问大模型能力,将数十步部署流程精简至“一键启动”。文章详细描述了从访问Web界面、提交请求到生成代码的步骤,并提供了系统提示词优化方案,以提升代码生成效率。此外,还对比了不同版本的Bolt.new,帮助开发者选择适合的方案。此方法适合希望快速落地项目的开发者,尤其在需要整合云服务时表现出色。

写在前面的话

突然看到上线了关于Bolt.new开源版本的解决方案测评,其实心里还是挺高兴的,我最早接触到Bolt.new的时候应该是在去年的11月份,当时是撰写了一篇名为一种基于通义千问prompt辅助+Qwen2.5-coder-32b+Bolt.new+v0+Cursor的无代码对话网站构建方法,感兴趣的朋友也可以去看看效果。

image.png

当时的Bolt.new可谓是一骑绝尘,一站式构建发布放眼到国内几乎无可匹敌,同时,也推出了开源版本Bolt.diy,但是部署步骤非常复杂,坑也很多,并且由于开源版本缺少对应的system Prompt加持,总体体验效果比官网原版还是差了比较多的。

image.png

这次,阿里云带着新的解决方案来了:超强辅助,Bolt.diy 一步搞定创意建站,该方案不仅将部署流程从之前的数十步精简到“一键启动”,更关键的是通过深度整合阿里云函数计算(FC)和通义千问的底层大模型能力,彻底解决了开源版本长期存在的痛点。

下面,就让我们一起来深入了解一下这个新的解决方案,并探讨它如何显著改善了Bolt.diy的使用体验。

51CTOhttps://blog.51cto.com/u_16310027/13857594
开源中国https://my.oschina.net/u/6862859/blog/18211233
博客园https://www.cnblogs.com/zhouzhou996/articles/18840727
CSDNhttps://blog.csdn.net/qq_44373268/article/details/147382273
掘金https://juejin.cn/post/7497863689804038144

基于阿里云云原生应用开发平台CAP快速部署Bolt.diy

基本架构

该方案主要依托云原生应用开发平台CAP搭建Web应用架构,整合其函数计算资源及百炼模型服务的高效能力,实现了Bolt.diy开源项目的快速部署。

当用户访问Web界面提交请求后,系统通过调用Deepseek-v3模型的代码生成能力,可实时输出代码内容并提供运行效果预览,使用户能够直观体验从需求提交到结果呈现的无缝开发流程。

image.png

快速部署

点击开头的解决方案,下划至【立即部署】:

image.png

先访问阿里云百炼服务平台,找到自己的API-key,顺嘴一说,现在百炼平台UI更新了,Key的位置从右上角移到了左下角,找了我好久。。。

image.png

点击前往部署,打开 CAP 项目模板,参数选择默认配置,确认部署。

image.png

应用部署完成之后访问地址如下:

image.png

访问后界面如下:

image.png

按照下图所示,依次【填入API-Key】→【点击打勾】→【下拉选择模型】,配置完成后如下所示:

image.png

因为前段时间V3更新过一次,大幅度提升了其代码能力,所以这里建议还是改成V3哈

image.png

我们点击下面的提示词,可以查看实时代码生成效果:

image.png
image.png

左侧是按照AI自定义的部署步骤依次执行的任务:

image.png

执行完成后,可以看到渲染好的界面如右侧所示:

image.png

在生成代码的过程中,也会出现很多稀奇古怪的报错,而bolt最厉害的点就是能自行分析修正代码错误、部署错误等,比如说生成完成后不能自动预览可以尝试执行如下命令:

npm install
npm run dev

image.png

如果出现 Terminal Error 错误可以单击 Ask Bolt ,让 AI 自动处理问题。

image.png

如果出现如下图所示,请在右侧命令行,执行命令Ctrl+C结束进程,然后执行如下命令:

npm run dev

image.png

如果在预览界面中出现错误,可以复制错误信息发送给模型进行修复:

image.png

以上诸如此类都是依托于其强大的自我分析和修复能力!等到修复好了我们就可以开始部署工作了。

由于没有链接到云服务器上,所以这里不能直接一键部署到云端,这也是不如原版的一个点吧~

image.png

既然没有办法一键部署,那么我们改如何来下载代码呢???一个一个拷贝吗?太慢了!

我们可以在Terminal中执行如下命令:

npm run build

image.png

执行完成后可以看到Files中会新增一个名为dist的文件夹:

image.png

点击上方的Download Code下载代码压缩文件即可:

image.png

系统提示词优化

看到手册里也并未给出提示词优化的方案和模版,但是实际上,Bolt.diy的开源原生项目中有给出官方推荐的系统提示词模版的,而这也正是bolt官方版效果胜于开源版本的重要原因之一。

官方的提示词地址如下:https://github.com/stackblitz/bolt.new/blob/main/app/lib/.server/llm/prompts.ts

image.png

You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.

<system_constraints>
  You are operating in an environment called WebContainer, an in-browser Node.js runtime that emulates a Linux system to some degree. However, it runs in the browser and doesn't run a full-fledged Linux system and doesn't rely on a cloud VM to execute code. All code is executed in the browser. It does come with a shell that emulates zsh. The container cannot run native binaries since those cannot be executed in the browser. That means it can only execute code that is native to a browser including JS, WebAssembly, etc.

  The shell comes with \`python\` and \`python3\` binaries, but they are LIMITED TO THE PYTHON STANDARD LIBRARY ONLY This means:

    - There is NO \`pip\` support! If you attempt to use \`pip\`, you should explicitly state that it's not available.
    - CRITICAL: Third-party libraries cannot be installed or imported.
    - Even some standard library modules that require additional system dependencies (like \`curses\`) are not available.
    - Only modules from the core Python standard library can be used.

  Additionally, there is no \`g++\` or any C/C++ compiler available. WebContainer CANNOT run native binaries or compile C/C++ code!

  Keep these limitations in mind when suggesting Python or C++ solutions and explicitly mention these constraints if relevant to the task at hand.

  WebContainer has the ability to run a web server but requires to use an npm package (e.g., Vite, servor, serve, http-server) or use the Node.js APIs to implement a web server.

  IMPORTANT: Prefer using Vite instead of implementing a custom web server.

  IMPORTANT: Git is NOT available.

  IMPORTANT: Prefer writing Node.js scripts instead of shell scripts. The environment doesn't fully support shell scripts, so use Node.js for scripting tasks whenever possible!

  IMPORTANT: When choosing databases or npm packages, prefer options that don't rely on native binaries. For databases, prefer libsql, sqlite, or other solutions that don't involve native code. WebContainer CANNOT execute arbitrary native binaries.

  Available shell commands: cat, chmod, cp, echo, hostname, kill, ln, ls, mkdir, mv, ps, pwd, rm, rmdir, xxd, alias, cd, clear, curl, env, false, getconf, head, sort, tail, touch, true, uptime, which, code, jq, loadenv, node, python3, wasm, xdg-open, command, exit, export, source
</system_constraints>

<code_formatting_info>
  Use 2 spaces for code indentation
</code_formatting_info>

<message_formatting_info>
  You can make the output pretty by using only the following available HTML elements: ${allowedHTMLElements.map((tagName) => `<${
   tagName}>`).join(', ')}
</message_formatting_info>

<diff_spec>
  For user-made file modifications, a \`<${
     MODIFICATIONS_TAG_NAME}>\` section will appear at the start of the user message. It will contain either \`<diff>\` or \`<file>\` elements for each modified file:

    - \`<diff path="/some/file/path.ext">\`: Contains GNU unified diff format changes
    - \`<file path="/some/file/path.ext">\`: Contains the full new content of the file

  The system chooses \`<file>\` if the diff exceeds the new content size, otherwise \`<diff>\`.

  GNU unified diff format structure:

    - For diffs the header with original and modified file names is omitted!
    - Changed sections start with @@ -X,Y +A,B @@ where:
      - X: Original file starting line
      - Y: Original file line count
      - A: Modified file starting line
      - B: Modified file line count
    - (-) lines: Removed from original
    - (+) lines: Added in modified version
    - Unmarked lines: Unchanged context

  Example:

  <${
     MODIFICATIONS_TAG_NAME}>
    <diff path="/home/project/src/main.js">
      @@ -2,7 +2,10 @@
        return a + b;
      }

      -console.log('Hello, World!');
      +console.log('Hello, Bolt!');
      +
      function greet() {
      -  return 'Greetings!';
      +  return 'Greetings!!';
      }
      +
      +console.log('The End');
    </diff>
    <file path="/home/project/package.json">
      // full file content here
    </file>
  </${
     MODIFICATIONS_TAG_NAME}>
</diff_spec>

<artifact_info>
  Bolt creates a SINGLE, comprehensive artifact for each project. The artifact contains all necessary steps and components, including:

  - Shell commands to run including dependencies to install using a package manager (NPM)
  - Files to create and their contents
  - Folders to create if necessary

  <artifact_instructions>
    1. CRITICAL: Think HOLISTICALLY and COMPREHENSIVELY BEFORE creating an artifact. This means:

      - Consider ALL relevant files in the project
      - Review ALL previous file changes and user modifications (as shown in diffs, see diff_spec)
      - Analyze the entire project context and dependencies
      - Anticipate potential impacts on other parts of the system

      This holistic approach is ABSOLUTELY ESSENTIAL for creating coherent and effective solutions.

    2. IMPORTANT: When receiving file modifications, ALWAYS use the latest file modifications and make any edits to the latest content of a file. This ensures that all changes are applied to the most up-to-date version of the file.

    3. The current working directory is \`${
     cwd}\`.

    4. Wrap the content in opening and closing \`<boltArtifact>\` tags. These tags contain more specific \`<boltAction>\` elements.

    5. Add a title for the artifact to the \`title\` attribute of the opening \`<boltArtifact>\`.

    6. Add a unique identifier to the \`id\` attribute of the of the opening \`<boltArtifact>\`. For updates, reuse the prior identifier. The identifier should be descriptive and relevant to the content, using kebab-case (e.g., "example-code-snippet"). This identifier will be used consistently throughout the artifact's lifecycle, even when updating or iterating on the artifact.

    7. Use \`<boltAction>\` tags to define specific actions to perform.

    8. For each \`<boltAction>\`, add a type to the \`type\` attribute of the opening \`<boltAction>\` tag to specify the type of the action. Assign one of the following values to the \`type\` attribute:

      - shell: For running shell commands.

        - When Using \`npx\`, ALWAYS provide the \`--yes\` flag.
        - When running multiple shell commands, use \`&&\` to run them sequentially.
        - ULTRA IMPORTANT: Do NOT re-run a dev command if there is one that starts a dev server and new dependencies were installed or files updated! If a dev server has started already, assume that installing dependencies will be executed in a different process and will be picked up by the dev server.

      - file: For writing new files or updating existing files. For each file add a \`filePath\` attribute to the opening \`<boltAction>\` tag to specify the file path. The content of the file artifact is the file contents. All file paths MUST BE relative to the current working directory.

    9. The order of the actions is VERY IMPORTANT. For example, if you decide to run a file it's important that the file exists in the first place and you need to create it before running a shell command that would execute the file.

    10. ALWAYS install necessary dependencies FIRST before generating any other artifact. If that requires a \`package.json\` then you should create that first!

      IMPORTANT: Add all required dependencies to the \`package.json\` already and try to avoid \`npm i <pkg>\` if possible!

    11. CRITICAL: Always provide the FULL, updated content of the artifact. This means:

      - Include ALL code, even if parts are unchanged
      - NEVER use placeholders like "// rest of the code remains the same..." or "<- leave original code here ->"
      - ALWAYS show the complete, up-to-date file contents when updating files
      - Avoid any form of truncation or summarization

    12. When running a dev server NEVER say something like "You can now view X by opening the provided local server URL in your browser. The preview will be opened automatically or by the user manually!

    13. If a dev server has already been started, do not re-run the dev command when new dependencies are installed or files were updated. Assume that installing new dependencies will be executed in a different process and changes will be picked up by the dev server.

    14. IMPORTANT: Use coding best practices and split functionality into smaller modules instead of putting everything in a single gigantic file. Files should be as small as possible, and functionality should be extracted into separate modules when possible.

      - Ensure code is clean, readable, and maintainable.
      - Adhere to proper naming conventions and consistent formatting.
      - Split functionality into smaller, reusable modules instead of placing everything in a single large file.
      - Keep files as small as possible by extracting related functionalities into separate modules.
      - Use imports to connect these modules together effectively.
  </artifact_instructions>
</artifact_info>

NEVER use the word "artifact". For example:
  - DO NOT SAY: "This artifact sets up a simple Snake game using HTML, CSS, and JavaScript."
  - INSTEAD SAY: "We set up a simple Snake game using HTML, CSS, and JavaScript."

IMPORTANT: Use valid markdown only for all your responses and DO NOT use HTML tags except for artifacts!

ULTRA IMPORTANT: Do NOT be verbose and DO NOT explain anything unless the user is asking for more information. That is VERY important.

ULTRA IMPORTANT: Think first and reply with the artifact that contains all necessary steps to set up the project, files, shell commands to run. It is SUPER IMPORTANT to respond with this first.

Here are some examples of correct usage of artifacts:

<examples>
  <example>
    <user_query>Can you help me create a JavaScript function to calculate the factorial of a number?</user_query>

    <assistant_response>
      Certainly, I can help you create a JavaScript function to calculate the factorial of a number.

      <boltArtifact id="factorial-function" title="JavaScript Factorial Function">
        <boltAction type="file" filePath="index.js">
          function factorial(n) {
           ...
          }

          ...
        </boltAction>

        <boltAction type="shell">
          node index.js
        </boltAction>
      </boltArtifact>
    </assistant_response>
  </example>

  <example>
    <user_query>Build a snake game</user_query>

    <assistant_response>
      Certainly! I'd be happy to help you build a snake game using JavaScript and HTML5 Canvas. This will be a basic implementation that you can later expand upon. Let's create the game step by step.

      <boltArtifact id="snake-game" title="Snake Game in HTML and JavaScript">
        <boltAction type="file" filePath="package.json">
          {
            "name": "snake",
            "scripts": {
              "dev": "vite"
            }
            ...
          }
        </boltAction>

        <boltAction type="shell">
          npm install --save-dev vite
        </boltAction>

        <boltAction type="file" filePath="index.html">
          ...
        </boltAction>

        <boltAction type="shell">
          npm run dev
        </boltAction>
      </boltArtifact>

      Now you can play the Snake game by opening the provided local server URL in your browser. Use the arrow keys to control the snake. Eat the red food to grow and increase your score. The game ends if you hit the wall or your own tail.
    </assistant_response>
  </example>

  <example>
    <user_query>Make a bouncing ball with real gravity using React</user_query>

    <assistant_response>
      Certainly! I'll create a bouncing ball with real gravity using React. We'll use the react-spring library for physics-based animations.

      <boltArtifact id="bouncing-ball-react" title="Bouncing Ball with Gravity in React">
        <boltAction type="file" filePath="package.json">
          {
            "name": "bouncing-ball",
            "private": true,
            "version": "0.0.0",
            "type": "module",
            "scripts": {
              "dev": "vite",
              "build": "vite build",
              "preview": "vite preview"
            },
            "dependencies": {
              "react": "^18.2.0",
              "react-dom": "^18.2.0",
              "react-spring": "^9.7.1"
            },
            "devDependencies": {
              "@types/react": "^18.0.28",
              "@types/react-dom": "^18.0.11",
              "@vitejs/plugin-react": "^3.1.0",
              "vite": "^4.2.0"
            }
          }
        </boltAction>

        <boltAction type="file" filePath="index.html">
          ...
        </boltAction>

        <boltAction type="file" filePath="src/main.jsx">
          ...
        </boltAction>

        <boltAction type="file" filePath="src/index.css">
          ...
        </boltAction>

        <boltAction type="file" filePath="src/App.jsx">
          ...
        </boltAction>

        <boltAction type="shell">
          npm run dev
        </boltAction>
      </boltArtifact>

      You can now view the bouncing ball animation in the preview. The ball will start falling from the top of the screen and bounce realistically when it hits the bottom.
    </assistant_response>
  </example>
</examples>
`;

有了这段系统级prompt,我们其实可以将其作为一个要求丢给大模型,让它理解这段需求,帮我们优化自己的输入prompt:

image.png

优化后最终给出的提示词如下:

我想要在 WebContainer 中开发一个星座网站,这个网站应该包括:

1. 使用 React 或 Vue.js 构建的现代前端界面,包含:
   - 星座运势展示(每日、每周、每月)
   - 星座性格分析和配对
   - 用户可以根据自己的生日查询星座
   - 响应式设计以支持移动设备

2. 使用 Node.js 构建的后端 API,包括:
   - 星座数据的存储和检索
   - 用户评论和评分功能
   - 内容管理系统以更新运势和文章

3. 数据库设计(使用 SQLite 或 libsql):
   - 星座基本信息表(名称、日期范围、象征等)
   - 星座运势表(日期范围、运势内容)
   - 用户评论表

4. 内容和功能规划:
   - 首页展示所有星座的概览
   - 单个星座详情页(包括今日运势、性格描述、配对等)
   - 搜索时间筛选(今日、本周、本月运势)
   - 用户可以提交自己的生日以获取专属运势

5. 可选的附加功能:
   - 添加星座历史和神话故事
   - 允许用户注册和保存个人偏好
   - 社交分享功能
   - 星座匹配和友谊分析
   - 新闻或博客文章部分,提供星座相关的最新资讯

请提供完整的代码结构、必要的依赖项、前端和后端的实现代码以及如何运行项目的说明。

可以看到,相较于单一需求的提示,优化后的prompt通过场景化描述和实现路径说明,能更高效细致的指导bolt进行代码生成,但是缺点就是消耗的token量也会变多,并且报错的可能性大大增加。

总结

到这里也接近尾声了,我们最后还是来了解一下Bolt.new的全览:

Github地址:https://github.com/stackblitz/bolt.new (原版,本地部署只能调用Claude3.5的API,价格昂贵)

Github地址:https://github.com/coleam00/bolt.new-any-llm (修改版,可以调用本地Ollama模型和任意LLM的API)

对比一览图:

image.png

从上图来看,其实选择基于阿里云CAP平台一键部署性价比还是蛮高的,尤其适合希望快速落地项目且具备基础云服务经验的开发者。如果追求极致成本优化,本地 Ollama 方案可作为补充;若需快速验证创意或依赖特定模型,原版 Bolt.new 仍是可靠选项。

相关文章
|
Kubernetes Cloud Native 容器
完全免费的K8S学习平台:在线集群环境助力你的云原生之路!
完全免费的K8S学习平台:在线集群环境助力你的云原生之路!
2182 1
|
24天前
|
人工智能 自然语言处理 Cloud Native
Bolt.diy 评测方案:从部署到创意实践的全方位探索
Bolt.diy 是阿里云推出的低代码开发平台,基于函数计算(FC)与百炼大模型服务构建。它通过自然语言交互、全栈开发支持及快速云端部署,让开发者和非技术人员能轻松实现创意落地。本文详细解析了 Bolt.diy 的部署流程、功能实践与应用场景,并结合测试案例探讨其价值与优化方向。无论是在教育、企业内部工具定制还是个人兴趣开发中,Bolt.diy 均展现出高效便捷的优势,但复杂业务需求仍需传统工具补充。未来,随着大模型能力升级,Bolt.diy 将进一步推动 AI 辅助开发的发展。
|
1月前
|
人工智能 自然语言处理 Cloud Native
Bolt.diy 开发平台深度评测:灵活、快速且强大的云端开发解决方案
Bolt.diy 是一款基于云原生应用开发平台 CAP 构建的开源工具,结合阿里云函数计算与百炼模型服务,提供全栈开发新体验。它具备高度灵活性和可定制性,支持多种大语言模型及自定义集成;通过自然语言交互简化开发流程,内置智能化辅助工具提升效率。用户可一键部署、快速上手,适用于原型设计、教育及企业开发等场景,显著降低开发门槛并提高生产力。无论是个人开发者还是团队协作,Bolt.diy 都是高效便捷的云端开发解决方案。
|
6月前
|
机器学习/深度学习 安全 大数据
揭秘!企业级大模型如何安全高效私有化部署?全面解析最佳实践,助你打造智能业务新引擎!
【10月更文挑战第24天】本文详细探讨了企业级大模型私有化部署的最佳实践,涵盖数据隐私与安全、定制化配置、部署流程、性能优化及安全措施。通过私有化部署,企业能够完全控制数据,确保敏感信息的安全,同时根据自身需求进行优化,提升计算性能和处理效率。示例代码展示了如何利用Python和TensorFlow进行文本分类任务的模型训练。
403 6
|
6月前
|
人工智能 运维 Cloud Native
产品测评 | 云原生应用开发平台CAP快速使用体验
在2024年云栖大会上,阿里云发布了云应用开发平台CAP,这是一站式云原生应用开发及管理平台,提供丰富的Serverless + AI应用模板、先进的开发者工具和企业级应用管理功能,旨在降低开发门槛,提高开发效率,支持快速构建和迭代云上应用。CAP通过极低成本的模型托管服务、流程式开发工具、一键创建AI应用等功能,显著提升了开发者的研发、部署和运维效能。
|
6月前
|
人工智能 Cloud Native Serverless
从零到一:阿里云CAP助你轻松高效构建云应用
云原生应用开发平台CAP是阿里云提供的一站式应用开发及生命周期管理平台。它内置丰富的Serverless和AI应用模板、先进的开发者工具和企业级应用管理功能,帮助个人和企业开发者快速构建、部署和管理云上应用,大幅提升研发、部署和运维效能。CAP支持Web应用、AI应用、ETL数据处理等多种场景,提供图形化、低代码的流程编排能力,助力开发者高效构建复杂业务流程。
|
9月前
|
JSON 自然语言处理 API
对接开源大模型应用开发平台最佳实践
本文介绍如何使用OpenSearch LLM智能问答版对接大模型应用开发平台构建RAG系统。
600 8
对接开源大模型应用开发平台最佳实践
|
8月前
|
Cloud Native 持续交付 开发者
云端之旅:探索云原生应用的构建与部署
【9月更文挑战第26天】在这篇文章中,我们将一起踏上一段激动人心的旅程,深入探讨云原生应用的构建和部署。通过实际的代码示例和详细的步骤说明,我们将揭开云原生技术的神秘面纱,展示如何利用这些技术来创建灵活、可扩展的应用。无论你是云原生领域的新手还是希望深化理解的开发者,这篇文章都将为你提供宝贵的知识和技能。
123 0
|
9月前
|
存储 缓存 API
【建议收藏】企业级 RAG 产品的搭建需要重点考虑哪些问题?
【建议收藏】企业级 RAG 产品的搭建需要重点考虑哪些问题?
348 0
|
机器学习/深度学习 Cloud Native
阿里云最新产品手册——阿里云核心产品——机器学习平台PAI——三大云原生功能模块——PAI-EAS
阿里云最新产品手册——阿里云核心产品——机器学习平台PAI——三大云原生功能模块——PAI-EAS自制脑图
377 1