欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 美景 > 解决方案评测|告别复杂配置!基于阿里云云原生应用开发平台CAP快速部署Bolt.diy

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

2025/4/23 22:53:14 来源:https://blog.csdn.net/qq_44373268/article/details/147382273  浏览:    关键词:解决方案评测|告别复杂配置!基于阿里云云原生应用开发平台CAP快速部署Bolt.diy

写在前面的话

突然看到上线了关于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的使用体验。

基于阿里云云原生应用开发平台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 fileThe 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 contextExample:<${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 systemThis 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 summarization12. 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 仍是可靠选项。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词