# 5分钟搭建本地AI编程助手：Yi-Coder模型与Cursor编辑器整合指南

By [wildcard教程](https://paragraph.com/@wildcard-10) · 2025-03-04

---

**Yi-Coder** 是一款开源的高性能代码语言大模型，专为高效编程设计。它支持52种编程语言，擅长处理需要长上下文理解的任务，如项目级代码理解和生成。该模型提供两种参数规模（15亿和90亿），并分为基础版和聊天版。

在本教程中，您将学习如何：

*   使用与OpenAI兼容的API在本地运行Yi-Coder模型
    
*   将Yi-Coder集成到Cursor编辑器
    

**Cursor** 是当前最热门的AI代码编辑器之一。它支持使用专门为编码任务训练的大语言模型（如Yi-Coder）来完成编码辅助任务。您可以将Yi-Coder-9B配置为Cursor的私有LLM后端。

本地运行Yi-Coder模型
--------------

要获取Cursor所需的本地Yi-Coder-9B的公共HTTPS端点，请按照以下步骤操作：

1.  安装开源Gaia节点——一组轻量且可移植的LLM推理工具。
    
    > Gaia的技术栈基于**WasmEdge**，这是一个专为无服务器计算和边缘应用优化的WebAssembly运行时。这种架构使得Yi-Coder能够在不同环境中高效部署，提供灵活性和可扩展性。
    
2.  使用以下命令安装Gaia节点：
    
    bash curl -sSfL '[https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh](https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh)' | bash
    
3.  下载并初始化模型：
    
    bash gaianet init --config [https://raw.githubusercontent.com/GaiaNet-AI/node-configs/main/yi-coder-9b-chat/config.json](https://raw.githubusercontent.com/GaiaNet-AI/node-configs/main/yi-coder-9b-chat/config.json)
    
4.  启动节点：
    
    bash gaianet start
    
    启动后，您将获得一个HTTPS URL，例如：`https://NODE-ID.us.gaianet.network`。
    
5.  您还可以在浏览器中访问 `http://localhost:8080` 来提问编程相关问题。
    

![Yi-Coder运行界面](https://storage.googleapis.com/papyrus_images/747a24bdb260bfc2715ebfdcca41ded39ebae944c5d9f4c7e14387926e25223f.webp)

Yi-Coder运行界面

> 我们以8k上下文窗口启动了Yi-Coder-9B模型。如果您的机器具有较大的GPU内存（例如24GB），则可以将上下文大小增加到128k。较大的上下文大小在编码中特别有用，因为我们需要将大量源代码文件塞入LLM提示中才能完成复杂的任务。

将Yi-Coder-9B集成到Cursor
---------------------

接下来，让我们使用在本地运行的Yi-Coder-9B配置Cursor。

1.  使用您的Gaia节点URL覆盖Cursor的默认OpenAI URL，并修复模型名称和“API密钥”。
    
2.  现在，您可以开始使用Yi-Coder-9B进行编码任务了！
    

让我们测试Yi-Coder-9B来编写一个简单的搜索页面。

![生成搜索页面](https://storage.googleapis.com/papyrus_images/48d3adf242ab2613770bd73d433dc644d44fe995ce40452f396610f3f371e961.webp)

生成搜索页面

我提示模型生成了一个简单的搜索页面。

![修改按钮标签](https://storage.googleapis.com/papyrus_images/5f970791951c77836f37eca88429f66c0544da28cfb5416c3228954ad872692c.webp)

修改按钮标签

然后，我要求Yi-Coder-9B修改按钮上的文字标签。Yi-Coder-9B解释了搜索按钮的工作原理。

![网页运行效果](https://storage.googleapis.com/papyrus_images/d09847f59ca29e87d7c694b17c665bc0c65824d064ef4ae288bc5cc1c2ee840e.webp)

网页运行效果

网页如预期运行！

👉 [野卡 WildCard | 一分钟注册，轻松订阅海外线上服务](https://bit.ly/yekapay)

参考资料
----

\[1\] Yi-Coder: \_[https://huggingface.co/blog/lorinma/yi-coder\_](https://huggingface.co/blog/lorinma/yi-coder_)

\[2\] WasmEdge: \_[https://github.com/WasmEdge/WasmEdge\_](https://github.com/WasmEdge/WasmEdge_)

\[3\] [http://localhost:8080](http://localhost:8080): \_[http://localhost:8080/\_](http://localhost:8080/_)

\[4\] 此处: \_[https://docs.gaianet.ai/user-guide/apps/cursor/#configure-cursor\_](https://docs.gaianet.ai/user-guide/apps/cursor/#configure-cursor_)

\[5\] LlamaEdge 文档: \_[https://llamaedge.com/docs/category/drop-in-replacement-for-openai\_](https://llamaedge.com/docs/category/drop-in-replacement-for-openai_)

\[6\] WasmEdge discord: \_[https://discord.com/invite/U4B5sFTkFc\_](https://discord.com/invite/U4B5sFTkFc_)

关于 WasmEdge
-----------

WasmEdge 是轻量级、安全、高性能、可扩展、兼容OCI的软件容器与运行环境。目前是 CNCF 沙箱项目。WasmEdge 被应用在 SaaS、云原生，service mesh、边缘计算、边缘云、微服务、流数据处理、LLM 推理等领域。

---

*Originally published on [wildcard教程](https://paragraph.com/@wildcard-10/5-ai-yi-coder-cursor)*
