DeepSite 是 Hugging Face 平台上一个流行的应用程序,它允许用户通过自然语言描述生成代码,实现氛围编程(Vibe coding)。DeepSite 使用了最新版本的 DeepSeek-V3-0324 模型,支持用户通过自然语言描述来生成代码,无需手动编写复杂的代码。介绍见:体验Hugging Face 平台上的DeepSite,实现氛围编程(Vibe coding)-CSDN博客
官方体验:DeepSite - a Hugging Face Space by enzostvs
但是官方在Huggingface,需要科学上网。有些小伙伴就会问了:
最简单的办法,是直接git clone我改好的版本,然后修改里面的openai的base_url、key和模型名字,npm 安装,npm start启动服务即可。
复杂点的办法,下载次官方的代码,然后修改里面的三个文件server.js package.json 和package-lock.json,让其跟Huggingface解耦并支持自定义llm模型调用即可。
git clone https://github.com/skywalk163/deepsite
cd deepsite
修改server.js文件里从262句开始的base_url、key和模型名字,参考:
const openai = new OpenAI({
baseURL: 'http://192.168.1.5:1337/v1',
apiKey: 'your-api-key', // 如果需要认证
});
async function chatCompletionStream(prompt) {
const stream = await openai.chat.completions.create({
model: 'deepseek-v3', // 你的模型名称
messages: [{ role: 'user', content: prompt }],
stream: true,
});
安装:
npm install
如果速度慢,就加上镜像
npm config set registry https://registry.npmmirror.com
再执行一下build:
npm run build
最后npm start启动就行了:
npm start
服务启动,访问端口是3000,用浏览器打开3000端口的web网页即可。
先从网上找到DeepSite的源码,找到了github上的镜像:mutalisk999/deepsite: mirror of https://huggingface.co/spaces/enzostvs/deepsite
将代码git clone到本地:
git clone https://github.com/mutalisk999/deepsite
进入源代码目录,npm安装、构建、启动一键三连!
cd deepsite
npm install
npm run build
npm start
还是那句话,如果速度慢,就加上镜像:
npm config set registry https://registry.npmmirror.com
然后用浏览器登录3000端口,测试项目。
这时候项目会调用Huggingface的推理,所以会推理失败,报错:
Error: Error: We have not been able to find inference provider information for model deepseek-ai/DeepSeek-V3-0324.
at getProviderModelId
(file:///home/skywalk/github/deepsite/node_modules/@huggingface/inference/dist/index.js:427:11)
需要修改index.js,修改成使用自定义的llm推理,而不是用Huggingface的推理。
另外还会有报错:you probably reached the MAX_TOKENS limit
这是因为整个系统都跟Huggingface耦合紧密,需要去掉这部分相关耦合代码。
根据收集到的问题,在Trae编辑器以及文心大模型的帮助下,修改代码,实现跟Huggingface的解耦,以及自建llm服务器的接入。
最终,修改了三个文件server.js package.json 和package-lock.json:
三个文件跟原文件相比,修改部分如下:
diff server.js ~/work/deepsite/server.js
185,207d184
< const { hf_token } = req.cookies;
< let token = hf_token;
< const ip =
< req.headers["x-forwarded-for"]?.split(",")[0].trim() ||
< req.headers["x-real-ip"] ||
< req.socket.remoteAddress ||
< req.ip ||
< "0.0.0.0";
<
< if (!hf_token) {
< // Rate limit requests from the same IP address, to prevent abuse, free is limited to 2 requests per IP
< ipAddresses.set(ip, (ipAddresses.get(ip) || 0) + 1);
< if (ipAddresses.get(ip) > MAX_REQUESTS_PER_IP) {
< return res.status(429).send({
< ok: false,
< openLogin: true,
< message: "Log In to continue using the service",
< });
< }
<
< token = process.env.DEFAULT_HF_TOKEN;
< }
<
213d189
< const client = new InferenceClient(token);
217,219c193,194
< const chatCompletion = client.chatCompletionStream({
< model: MODEL_ID,
< provider: "fireworks-ai",
---
> const stream = await openai.chat.completions.create({
> model: 'deepseek-v3', // 你的模型名称
247c222
< max_tokens: 12_000,
---
> stream: true,
250,252c225,231
< while (true) {
< const { done, value } = await chatCompletion.next();
< if (done) {
---
> for await (const chunk of stream) {
> const content = chunk.choices[0]?.delta?.content || '';
> res.write(content);
> completeResponse += content;
>
> // Break when HTML is complete
> if (completeResponse.includes("