AI程序员(aider)+ollama+DeepSeek-R1安装配置和使用

AI程序员(aider)+ollama+DeepSeek-R1安装配置和使用

概述

aider其实是ai coder的缩写,可以说是一个ai programmer,可以根据需求编写代码,可以分析代码,重构代码等。比一般的代码助手更加智能。目前还处于比较初级的版本,但已经具备一定的可用性。

本文介绍aider的本地部署和使用,通过ollama的部署和使用可以让aider使用本地部署的大模型。比如:qwen或deepseek等。ollama的安装和模型的拉取,可以参考我前面的文章,这里不再赘述。

安装aider

python -m pip install aider-install
# 安装依赖包
aider-install

安装ollama对应的环境变量

python -m pip install -U aider-chat

export OLLAMA_API_BASE=http://127.0.0.1:11434 # Mac/Linux

设置启动aider使用的模型

在启动aider时指定使用的模型。我这里使用ollama中的Qwen2.5:7b这个本地模型。

aider --model ollama_chat/Qwen2.5:7b
# 或者
aider --model ollama_chat/deepseek-r1:8b

配置文件

若不指定配置文件,则会使用默认的配置项。可以从这里下载配置文件样例:样例配置文件。可以通过以下参数来指定配置文件:

aider --config .aider.conf.yml

环境变量文件:可以通过.env来指定环境变量。并通过以下命令来指定环境变量文件。环境变量的设置样例文件在这里下载。

aider --env .env

启动并使用

我这里并没有配置.env和aider.conf配置文件,使用默认配置,但指定了ollama的地址,所以我写了一个启动的shell脚本:start_aider.sh,可以直接启动aider:

export OLLAMA_API_BASE=http://127.0.0.1:11434
aider --model ollama_chat/Qwen2.5:7b "$1"

启动后是一个命令行,可以有多种命令,比如:/add,/chat-mod等。

一般来说启动时我要设置一个或多个文件名,这样才能对这些文件进行读取和处理,我这里直接给它指令:

$ start_aider.sh  "snake.py"                         
> 请帮我写一个贪吃蛇的游戏
好的,我将为您编写一个简单的贪吃蛇游戏。我们将创建一个新的文件 snak.py 来实现这个游戏。                 
...
...
# 这里是很多代码的输出
...
这个简单的贪吃蛇游戏包含了一个 Snake 类来表示蛇,一个 Food 类来表示食物,以及一个 Game                                         
类来管理游戏逻辑。游戏通过控制台输入方向来移动蛇,并在吃到食物时生成新的食物位置。当蛇撞到自己或边界时,游戏结束。             

Tokens: 1.0k sent, 701 received.
Committing snake_v3.py before applying edits.
Commit b6bfdbb feat: add snake.py
Applied edit to snake.py
Commit 73aabf9 feat: 添加贪吃蛇游戏实现
You can use /undo to undo and discard each aider commit.

aider会把游戏的代码写到snake.py这个文件中。若有语法错误,还会给你检查并提示你是否需要修改。

使用deepseek-r1来分析一个代码仓库

我下载了一个2048游戏仓库的代码,保存到2048文件夹中。然后通过aider来分析该代码。整个过程如下:

$ cd /work/aider/aider_lab/2048
$ aider --model ollama_chat/deepseek-r1:8b
────────────────────────────────────────────────────────────────────────────────────────────────
You can skip this check with --no-gitignore
Add .aider* to .gitignore (recommended)? (Y)es/(N)o [Yes]: n                                                                   
Aider v0.74.2
Model: ollama_chat/deepseek-r1:8b with diff edit format
Git repo: .git with 34 files
Repo-map: using 4096 tokens, auto refresh
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> /ls                                                                                                                          

Repo files not in the chat:

  .gitignore
  .jshintrc
  CONTRIBUTING.md
  LICENSE.txt
  README.md
  Rakefile
  favicon.ico
  index.html
  js/animframe_polyfill.js
  js/application.js
  js/bind_polyfill.js
  js/classlist_polyfill.js
  js/game_manager.js
  js/grid.js
  js/html_actuator.js
  js/keyboard_input_manager.js
  js/local_storage_manager.js
  js/tile.js
  meta/apple-touch-icon.png
  meta/apple-touch-startup-image-640x1096.png
  meta/apple-touch-startup-image-640x920.png
  style/fonts/ClearSans-Bold-webfont.eot
  style/fonts/ClearSans-Bold-webfont.svg
  style/fonts/ClearSans-Bold-webfont.woff
  style/fonts/ClearSans-Light-webfont.eot
  style/fonts/ClearSans-Light-webfont.svg
  style/fonts/ClearSans-Light-webfont.woff
  style/fonts/ClearSans-Regular-webfont.eot
  style/fonts/ClearSans-Regular-webfont.svg
  style/fonts/ClearSans-Regular-webfont.woff
  style/fonts/clear-sans.css
  style/helpers.scss
  style/main.css
  style/main.scss
────────────────────────────────────────────────────────────────────────────────────────────────
# 开始提问
> what is this repo?                                                                                                           
Looking at the files, it seems like it's a JavaScript game project. There are directories like js, style, meta, and others,    
which typically make up a web app. The presence of game-related files (like Tile.js, Grid.js) indicates this is probably a     
puzzle or matching game, given the tile movements and scoring mechanics mentioned in the code.                                 
The user also included various polyfills for JavaScript features, like classList and requestAnimationFrame, which are common in
older browser compatibility projects. This tells me the project might be targeting older browsers that don't support these     
features natively.                                                                                                             
They have a LocalStorageManager and a KeyboardInputManager, which are essential for handling game state and user input. The    
HTMLActuator suggests they're using DOM elements to display the game, with tiles being created as divs in the DOM.             

The style files include SCSS and CSS, so they're using a preprocessor on the frontend side. The presence of webfonts and icons 
also points towards a polished web app.                                                                                        

Considering all this, the repo is likely a single-page web application built with HTML, JavaScript, and CSS, focusing on a     
tile-matching game with features like score tracking, best scores, and basic animations.                                       

I should break down the structure into key components to help the user understand their project better. I'll list out the      
directories and the main files each handles, providing a clear overview without making any changes.                            

Based on the files shown, this appears to be a JavaScript game development project that likely focuses on a tile-matching or   
puzzle-type game. Let me analyze the structure:                                                                                

Key directories and their purposes:                                                                                            

 1 js/: 
 • Contains core game logic modules like application.js, game_manager.js, grid.js, etc.         
 • Has polyfills for browser APIs like requestAnimationFrame, classList, etc.                                                  
 2 style/:
 • Contains CSS stylesheets and SCSS files                                                       
 • Includes font definitions and UI-related styling                                                                            
 3 meta/:                                                                                       
 • Contains apple-touch-icon and startup image files
 • Indicates this is a web app with native touch support                                         
 
 4 js/storage/:
 • Contains LocalStorageManager implementation
 • Manages game state and scores
 
 5 js/tile/:                                                                                     
 • Core tile class that seems to handle movement and merging logic                                
 6 js/html_actuator/:
 • Handles DOM updates for rendering tiles
 • Includes animation frame management                                                              
 7 Other files: 
 • Various configuration files like .gitignore, LICENSE, etc.
 • Font files in the style directory
 • HTML file at index.html                                                                                                     
The most likely files that would need changes based on common requests include:                                                
 1 js/game_manager.js: Core game logic and state management
 2 style/main.scss: Global styles for the app
 3 js/html_actuator.js: DOM rendering and animations
 4 js/local_storage_manager.js: Game progress persistence 

Would you like me to proceed with any specific changes to these files or other parts of your project?                          

Tokens: 6.2k sent, 673 received.

.gitignore
Add file to the chat? (Y)es/(N)o/(A)ll/(S)kip all/(D)on't ask again [Yes]: n                                                   
index.html
Add file to the chat? (Y)es/(N)o/(A)ll/(S)kip all/(D)on't ask again [Yes]: n    

可以看到,aider能够分析代码仓库的结构。

总结

本文是aider的一个初步尝试,可以看到aider还是比较强大和智能。但也存在一些缺陷,比如:再多多个文件进行代码分析是有时会有问题。另外,当代码的长度太长时,会有token的限制。这里也是ai coder需要解决的难点:如何在有限token的情况下,保证答案的质量。

另外,不同推理大模型的表现也不同,可以通过这种方式来配置不同的大模型。

参考资料

  • 样例配置文件:https://github.com/Aider-AI/aider/blob/main/aider/website/assets/sample.aider.conf.yml
  • https://aider.chat/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/970795.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

04性能监控与调优篇(D5_JVM优化)

目录 一、我们为什么要对jvm做优化? 二、jvm的运行参数 1. 三种参数类型 1.1. 标准 1> 参数介绍 2> 实战 3> -server与-client参数 1.2. -X参数 1> 参数介绍 2> -Xint、-Xcomp、-Xmixed 1.3. -XX参数 -Xms与-Xmx参数 2. 查看jvm的运行参…

IntelliJ IDEA 接入 AI 编程助手(Copilot、DeepSeek、GPT-4o Mini)

IntelliJ IDEA 接入 AI 编程助手(Copilot、DeepSeek、GPT-4o Mini) 📊 引言 近年来,AI 编程助手已成为开发者的高效工具,它们可以加速代码编写、优化代码结构,并提供智能提示。本文介绍如何在 IntelliJ I…

嵌入式软件、系统、RTOS(高软23)

系列文章目录 4.2嵌入式软件、系统、RTOS 文章目录 系列文章目录前言一、嵌入式软件二、嵌入式系统三、嵌入式系统分类四、真题总结 前言 本节讲明嵌入式相关知识,包括软件、系统。 一、嵌入式软件 二、嵌入式系统 三、嵌入式系统分类 四、真题 总结 就是高软笔记…

spring 学习 (注解)

目录 前言 常用的注解 须知 1 Conponent注解 demo(案例) 2 ControllerServiceRepository demo(案例) 3 ScopeLazyPostConstructPreDestroy demo(案例) 4 ValueAutowiredQualifierResource demo(案例) 5 Co…

C语言中qsort函数使用技巧

在C语言的标准库中, qsort 函数是一个强大的通用排序函数,它采用快速排序算法,能够高效地对各种数据类型的数组进行排序。掌握 qsort 函数的使用技巧,对于提升程序的效率和代码的简洁性至关重要。 一、qsort函数基本介绍 qsort 函…

python+deepseek进行个股分析

背景:deepseek无法获取最新的行情数据,需要手动喂给它 一 用python获取最新的个股数据 请参考我的另外一篇文章:[python获取个股的行情数据](稍微改造下导出数据到excel中)(https://blog.csdn.net/weixin_43006743/…

Golang官方编程指南

文章目录 1. Golang 官方编程指南2. Golang 标准库API文档 1. Golang 官方编程指南 Golang 官方网站:https://go.dev/ 点击下一步,查看官方手册怎么用 https://tour.go-zh.org/welcome/1 手册中的内容比较简单 go语言是以包的形式化管理函数的 搜索包名…

linux常用命令大全(包括抓包、网络检测、路由等,做项目一点点总结而来!)

文章目录 常用命令**apt相关****ls**:**cd****cp****ls -l | grep ssh**:会列出当前目录中包含 “ssh” 的文件或目录的详细信息。**系统资源**linux路由相关抓包工具和命令tcpdumpwiresharktshark iperf 常用命令 通过上下方向键 ↑ ↓ 来调取过往执行过…

HCIA项目实践--RIP相关原理知识面试问题总结回答

9.4 RIP 9.4.1 补充概念 什么是邻居? 邻居指的是在网络拓扑结构中与某一节点(如路由器)直接相连的其他节点。它们之间可以直接进行通信和数据交互,能互相交换路由信息等,以实现网络中的数据转发和路径选择等功能。&am…

[c语言日寄]字符串的左旋与右旋

【作者主页】siy2333 【专栏介绍】⌈c语言日寄⌋:这是一个专注于C语言刷题的专栏,精选题目,搭配详细题解、拓展算法。从基础语法到复杂算法,题目涉及的知识点全面覆盖,助力你系统提升。无论你是初学者,还是…

基于单片机的开关电源设计(论文+源码)

本次基于单片机的开关电源节能控制系统的设计中,在功能上设计如下: (1)系统输入220V; (2)系统.输出0-12V可调,步进0.1V; (3)LCD液晶显示实时电压&#xff…

日常知识点之遗留问题梳理(被问到用uml画设计模式)

好多年不接触uml了,有一天面试,让用uml画出设计模式, 已经对uml的概念很模糊,隐约记得就是用例图,类图之类的,后面确定后,就是类图,用例图,时序图,都属于uml…

索引以及索引底层数据结构

一、什么是索引? 索引(index)是数据库高效获取数据的数据结构(有序)。在数据之外,数据库系统还维护着满足特定查找算法的数据结构(B树),这些数据结构以某种方式指向真在…

搭建Deepseek推理服务

概述: 本文介绍用Open webui ollama搭建一套Deepseek推理服务,可以在web页面上直接进行对话。作为体验搭建的是Deepseek 7b参数版本 首先选择一个云厂商创建一台ubuntu系统的虚拟机,带公网IP,通过shell登录虚拟机完成以下操作&…

如何在C++中使用YOLO模型进行目标检测

《------往期经典推荐------》 一、AI应用软件开发实战专栏【链接】 项目名称项目名称1.【人脸识别与管理系统开发】2.【车牌识别与自动收费管理系统开发】3.【手势识别系统开发】4.【人脸面部活体检测系统开发】5.【图片风格快速迁移软件开发】6.【人脸表表情识别系统】7.【…

【第10章:自然语言处理高级应用—10.4 NLP领域的前沿技术与未来趋势】

各位技术探险家们,今天我们要开启一场穿越语言智能奇点的时空之旅。从正在改写物理定律的万亿参数大模型,到能看懂《星际穿越》剧本的跨模态AI,再到正在颠覆编程方式的神经-符号混合系统……这篇万字长文将带你摸清NLP技术进化的七块关键拼图。(建议边读边做笔记,文末有技…

SpringBoot+微信小程序+数据可视化的宠物到家喂宠服务(程序+论文+讲解+安装+调试+售后等)

感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,我会一一回复,希望帮助更多的人。 系统介绍 在经济高速发展、物质生活极大丰富的当下,人们的精神需求愈发凸显&#xff0…

案例-06.部门管理-根据ID查询

一.根据ID查询-接口文档 二.根据ID查询-Controller层 package com.gjw.controller;/*** 部门管理Controller*/import com.gjw.anno.Log; import com.gjw.pojo.Dept; import com.gjw.pojo.Result; import com.gjw.service.DeptService; import com.gjw.service.impl.DeptServi…

C++17中的LegacyContiguousIterator(连续迭代器)

文章目录 特点内存连续性与指针的兼容性更高的性能 适用场景与C接口交互高性能计算 支持连续迭代器的容器示例代码性能优势缓存局部性指针算术优化 注意事项总结 在C17标准里,LegacyContiguousIterator(连续迭代器)是一类特殊的迭代器。它不仅…

【Kubernetes】k8s 部署指南

1. k8s 入门 1.1 k8s 简介 需要最需要明确的就是:kubernetes(简称 k8s ) 是一个 容器编排平台 ,换句话说就是用来管理容器的,相信学过 Docker 的小伙伴对于容器这个概念并不陌生,打个比方:容器…