背景

Github上支持对PR生成AI摘要信息,具体说明

有没有应用支持生成提交内容的摘要信息呢?

AI Commits

经过一番搜索,找到了IDEA插件 AI Commits

功能

  1. 支持多个AI服务
  2. 支持多语言
  3. 支持自定义Prompt

支持的服务

OpenAI

不支持国内访问,可使用国内转发进行访问,但需要有token,免费的token对token长度有限制,最大4098

👍Ollama

官网,功能完全免费,多种开源模型可用,无使用限制,但需要本地部署,对机器内存有要求

推荐的开源模型如下:

  1. codeqwen
  2. deepseek-coder-v2

Qianfan

百度的AI模型千帆,https://qianfan.cloud.baidu.com/

需要以下操作方可正常使用

  1. 登录百度账号
  2. 创建应用id
  3. 开通模型计费且需要进行实名(银行卡/人脸)

开通后在AI Commits的Qianfan模型中设置API key和Secret key

Gemini

不支持国内访问,有用量限额

插件使用

选择LLM Client和Prompt

在AI Commits中配置好使用的LLM Client 和 Prompt,如选择 OpenAI 和名为 Basic 的Prompt

修改git项目代码

修改项目文件代码,比如加一行日志打印

提交代码

  • 进行提交代码界面,在提交信息栏多出一个 AI Commits 的图标,点击图标

  • 点击后生成的提交信息

  • 使用Ollama的gemma2:9b生成的提交信息

关于Prompt

插件默认自带了3个Prompt,插件的仓库提供更多的Prompt使用,点击插件配置页面的 More prompts 即可跳转

其它有意思的Prompt

  • 特朗普风格

    懂王风格

    1
    2
    3
    4
    5
    6
    
    Write an insightful but concise Git commit message in Donald Trump style in present tense for
    the following diff without prefacing it with anything, the response must be in the language {locale}
    and must not be longer than 74 characters. The sent text will be the differences between files,
    where deleted lines are prefixed with a single minus sign and added lines are prefixed with a
    single plus sign.
    {diff}
    
  • 增强版本的emoji风格

    对提交类型进行详细的分类,支持emoji

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    
    Using the diff provided below, create a concise commit message following the Conventional Commits format (e.g., " fix(types): corrected imports in types"). Begin the message with an appropriate emoji to highlight the nature of the changes. Use the past tense and first person for articulation. Ensure the line does not exceed 74 characters. Write in {locale}. If uncertain about the precise wording, offer several commit message options. Your response should consist solely of the commit message, without additional descriptions. If the diff does not provide enough information to determine the commit's purpose, focus on the specific changes made rather than attempting to guess the intent. Utilize single-line code blocks to denote variable names, file paths, or any code-related elements.
    
    Emoji Usage Guide:
    -  fix: For bug fixes.
    - ✨ feat: For new features.
    -  docs: For documentation changes.
    -  refactor: For code refactoring without changing functionality.
    -  perf: For performance improvements.
    -  security: For security-related fixes.
    -  chore: For maintenance tasks.
    -  test: for test related chagnes
    
    {Author's notes: "$hint"}
    
    Avoid verbosity, here is an output of `git diff --staged` command:
    {diff}
    
  • 其它待发掘?