AutoDev 1.1.3 登场,个性化 AI 辅助:私有化大模型、自主设计 prompt、定义独特规则...

在过去的半个月里,我们为开源辅助编程工具 AutoDev 添加了更强大的自定义能力,现在你可以:

  • 使用自己部署的开源大模型

  • 自己配置 Intellij IDEA 中的行为

  • 自定义开发过程中的规范

当然了,如果您自身拥有开发能力的话,建议您自己基于 AutoDev 定制。毕竟,为 AutoDev 添加太多的自定义能力,会导致架构的复杂性螺旋上升。

AutoDev 现在已支持多语言(不同语言能力有所差异)、多 IDE,因此只在 JetBrains 任何一个本地 IDE 的插件市场里,搜索 AutoDev 并安装 即可。

自定义大语言模型

我们通过 Thoughtworks 正在的开源底层模型平台 Gluon Meson,构建了一个统一的大语言模型接口。随后,我们测试了切换几个开源模型:清华大学 ChatGLM2-6B、阿里云通义千问 Qwen-7B 等,均可以流畅使用 ------ 模型太小,在诸如需要上下文补全的能力没有那么强。

考虑到提供更好的开发者体验,现在的 AutoDev 只支持服务端的流式返回,为此我们在源码中提供了一个 FastAPI + EventSourceResponse 的示例作为参考。

请求结构

我们发送给服务端的接口将类似于:

go 复制代码
{
  "messages": [
     { "role": "user", "message": "I'm Nihillum." },
     { "role": "assistant", "message": "OK" },
     { "role": "user", "message": "What did I just say?" }
  ]
}

根据现有的 #25 issue 设计情况,我们也将在未来提供更多的可配置的 headers 等

响应结果

对于结果来说,为了方便支持不同的模型,我们使用了 JSON Path 来处理返回结果。如下是一个简单的 JSON Path 的配置示例。

go 复制代码
$.choices[0].content

随后,将从 content 中取值,并处理。

详细见 README.md 中的 Custom LLM Server 部分。

自定义 prompt 行为项

为了配合不同大模型的能力差异,我们参考了 JetBrains AI Assistant 的设计,也在 AutoDev 中引入了自定义行为的方式,即你可以自定义自己的行为,并配置 prompt 的上下文。诸如于,你可以自定义一个将 Rust 转为 Kotlin 语言的行为项:

为此,只需要添加一个对应的 JSON 配置即可:

go 复制代码
{
  "prompts": [
    {
      "title": "\uD83C\uDDE8\uD83C\uDDF3 翻译成 Kotlin",
      "autoInvoke": false,
      "matchRegex": ".*",
      "priority": 1000,
      "template": "Translate the following code to Kotlin.\n${SIMILAR_CHUNK}\nCompare these snippets:\n${METHOD_INPUT_OUTPUT}\nHere is the code:\n${SELECTION}"
    }
  ]
}

其中的 priority 是用来配置在菜单中的顺序,template 则是发送给 LLM 的 prompt。除此,在 template 中,为了更好的支持一些高级的特征,我们配置了一些上下文变量:

  • ${``SELECTION}:所选代码

  • ${``SIMILAR_CHUNK}:相似的代码片段

  • ${``METHOD_INPUT_OUTPUT}:方法的输入与输出

规范变量:

  • ${``SPEC_*}:从配置文件的规范部分加载规范,比如 ${``SPEC_controller}将会从配置中加载 spec.controller

详细见 README.md 中的 Custom Action 部分。

自定义规范

在自定义操作项中,我们会定义一些不同任务的配置规则,诸如于 SPEC_controller 便会从 spec 中读取对应的内容,作为配置 prompt 的一部分:

go 复制代码
{
  "spec": {
    "controller": "- Use BeanUtils.copyProperties in the Controller for DTO to Entity conversion.\n- Avoid using Autowired.\n- Use Swagger Annotations to indicate API meanings.\n- Controller methods should capture and handle business exceptions, rather than throwing system exceptions.",
    "service": "- Service layer should use constructor injection or setter injection; avoid using the @Autowired annotation.",
    "entity": "- Entity classes should use JPA annotations for database mapping.\n- The entity class name should match the corresponding database table name. Entity classes should use annotations to mark primary keys and table names, for example: @Id, @GeneratedValue, @Table, etc.",
    "repository": "- Repository interfaces should extend the JpaRepository interface to inherit basic CRUD operations.",
    "ddl": "- Fields should be constrained with NOT NULL constraints to ensure data integrity."
  }
}

然后,你就可以愉快地进行 AI 辅助编程了。

小结

如果大家遇到什么问题或者有什么好玩的新需求,欢迎来 GitHub 讨论:https://github.com/unit-mesh/auto-dev

相关推荐
测试开发技术8 小时前
什么样的 prompt 是好的 prompt?
人工智能·ai·大模型·prompt
爱喝白开水a1 天前
LangChain 基础系列之 Prompt 工程详解:从设计原理到实战模板_langchain prompt
开发语言·数据库·人工智能·python·langchain·prompt·知识图谱
cooldream20091 天前
LangChain PromptTemplate 全解析:从模板化提示到智能链构
langchain·prompt·prompttemplate
serve the people1 天前
LangChain 表达式语言核心组合:Prompt + LLM + OutputParser
java·langchain·prompt
梵得儿SHI1 天前
Prompt Engineering 核心知识:从基础模式到思维链,掌握大模型高效交互秘籍
大模型·prompt·交互·提示词·对话·大模型提问艺术·极简指令
jimmyleeee1 天前
人工智能基础知识笔记十八:Prompt Engineering
笔记·prompt
非晓为骁2 天前
AI-Native 能力反思(三):Prompt Engineering 自我提升神器
人工智能·ai·prompt·ai-native·提示词工程
猫头虎5 天前
Paper2Agent:将科研论文转化为可交互的AI智能体工具项目
人工智能·prompt·aigc·交互·pip·agi·ai-native
声网5 天前
阿里发布「夸克 AI 眼镜」:融合阿里购物、地图、支付生态;苹果拟收购计算机视觉初创 Prompt AI丨日报
人工智能·计算机视觉·prompt