ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

一、安装ollama 方式

方式一: 官网下载安装文件

https://ollama.com/ ollama 的官网网站,选择相应的电脑版本下载和安装。

方式二:使用 brew install

brew install ollama

安装完后,记得打开 ollama 这个应用,确保应用是打开的。

打开 iterm 或 terminal 输入 ollama 命令看看,是否可执行。

ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

二、下载 qwen2.5-coder

ollama 官网可以查看全球各种开源的 LLM 模型,qwen2.5-coder 是目前最受欢迎之一。

打开 https://ollama.com/library/qwen2.5-coder 选择合适自己的模型,一般默认就是7b-instruct 的版本。我下载的是 32b 版本的,爱折腾的人可以看看各个量化版本效果。

打开 terminal 或 iterm2 输入命令,命令在 ollama 的页面选择模型会自动显示出来

ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码
ollama run qwen2.5-coder

回车执行命令后, ollama 会自动去下载 7b 模型 (网络问题自己解决),下载完后会自动进入对话,你可以任意输入中文或英文,会看到自动回复。输入/bye 命令,即可退出。

ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

退出来后 输入以下命令 看看下载了哪些模型

ollama list
ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

三、VS Code 安装 Continue 插件

在 VS Code 的扩展中,搜索 continue 插件,并安装。安装完后,打开 continue 的窗口。

点击最下面 config 文件自定义编辑,也可以选择你下载好 qewn2.5-coder, 点击 connect。

ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

我 Continue 的 config 文件配置如下:

{
   
"models": [
{
   
"model": "qwen2.5-coder:32b", // 32b的用来提问的时候用
"title": "qwen2.5-coder:32b",
"provider": "ollama",
"systemMessage": "You are an expert software developer. You give helpful and concise responses."

},
{
   
"title": "Qwen 2.5 Coder 7b",
"model": "qwen2.5-coder:latest",
"provider": "ollama",
"systemMessage": "You are an expert software developer. You give helpful and concise responses."
}
],
"tabAutocompleteModel": {
   
"title": "Tab Autocomplete", 
"provider": "ollama",
"model": "qwen2.5-coder:latest" //使用 7b 的自动扩写代码,速度会快点。 官方说用 base版本会更好,不要 instruct 

},

"customCommands": [
{
   

"name": "test",
"prompt": "{
   {
   { input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
"description": "Write unit tests for highlighted code"

}

],

"contextProviders": [

{
   

"name": "code",
"params": {
   }
},

{
   
"name": "docs",
"params": {
   }
},
{
   
"name": "diff",
"params": {
   }
},
{
   
"name": "terminal",
"params": {
   }
},
{
   
"name": "problems",
"params": {
   }
},
{
   
"name": "folder",
"params": {
   }
},
{
   
"name": "codebase",
"params": {
   }
}
],
"slashCommands": [
{
   
"name": "share",
"description": "Export the current chat session to markdown"
},
{
   
"name": "cmd",
"description": "Generate a shell command"
},
{
   
"name": "commit",
"description": "Generate a git commit message"
}
],
"embeddingsProvider": {
   
"provider": "ollama", // 用可以使用默认的 free-trial
"model": "bge-m3:latest"
},
"reranker": {
   
"name": "free-trial"
}
}
ollama+qwen2.5-coder+VS Code+Continue 实现本地AI 辅助写代码

Continue 插件的使用文档 https://docs.continue.dev/

阅读剩余 88%

转载作品,原作者:,文章来源:https://developer.aliyun.com/article/1639814

(0)
打赏 微信赞赏 微信赞赏 支付宝赞赏 支付宝赞赏
上一篇 2025-03-03 16:32
下一篇 2025-03-06 13:29

相关推荐

发表回复

登录后才能评论
扫码了解
扫码了解
反馈建议
分享本页
返回顶部