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

相关推荐
Swizard11 小时前
还在无脑堆砌提示词?三分钟看懂 Vercel v0 价值千万的 System Prompt 底层逻辑
ai·prompt
Loo国昌12 小时前
【AI应用开发实战】Guardrail风险控制中间件:Agent系统的安全防线
人工智能·python·安全·自然语言处理·中间件·prompt
啦啦啦_999912 小时前
SpringAI Alibaba(SAA) 之 Prompt
prompt
AC赳赳老秦12 小时前
DeepSeek助力云原生AI降本:容器化部署资源优化与算力利用率提升技巧
网络·python·django·prompt·tornado·ai-native·deepseek
Loo国昌1 天前
【AI应用开发实战】09_Prompt工程与模板管理:构建可演进的LLM交互层
大数据·人工智能·后端·python·自然语言处理·prompt
minhuan1 天前
大模型应用:遗传算法 (GA)+大模型:自动化进化最优Prompt与模型参数.95
prompt·大模型应用·遗传算法 ga·prompt自动调优
Loo国昌1 天前
【AI应用开发实战】06_向量存储与EmbeddingProvider设计
人工智能·后端·python·语言模型·自然语言处理·prompt
光的方向_2 天前
从原理到实践:深度解析Transformer架构——大模型时代的核心基石
人工智能·chatgpt·prompt·transformer
XLYcmy2 天前
chatgpt数据库检索文献 上
ai·chatgpt·llm·prompt·检索·gpt-4o·doi
XLYcmy3 天前
chatgpt数据库检索文献 下
ai·chatgpt·llm·prompt·agent·检索·多轮对话