Skip to content

The best AI assistant for your Github repository, it can not only help you automatically translate issues/discussions/pr/commit to the specified language, but also help you with code review, automatic code repair and other functions through AI models.您Github存储库的最佳AI助手, 它不但可以帮助您自动翻译issues/discussions/pr/commit到指定语言, 还可以通过AI模型帮助您进行代码审查, 代码自动修复等功能

License

Notifications You must be signed in to change notification settings

lx6317648/Github-AI-Assistant

 
 

Repository files navigation

Github AI Assistant

[GitHub issues]

Your best AI assistant for GitHub repositories, it not only helps you automatically translate issues/discussions/PRs/commits into the specified language, but also performs code review and automatic code fixes by vectorizing the entire project to generate detailed context and submitting it to the AI, similar to the implementation of cursor.

中文

Features

  • Automatically translate specified issues/discussions/PRs/commits to English or a designated language
  • Batch translate all issues/discussions/PRs of a repository to English or a designated language
  • Option to use GPT series or GEMINI series models for translation (or any model compatible with OpenAI interface)
  • Retain the original text alongside the English translation
  • Automatically add markers after translation to English to prevent duplicate translations
  • Built-in webhook server for automatic translation of issues/discussions/PRs/commits to English or other languages
  • Support for pre-translation by modifying JSON files in the data directory
  • Use of asynchronous coroutines for translation to improve efficiency
  • Provide two translation backends, with options to use sentence splitting translation or direct translation, and the ability to extend translation backends
  • Support for manual or webhook-triggered automatic code review of submitted PRs or commits, providing suggestions for fixes and optimizations, for example: here
  • Supports code review based on code tree segmentation and vectorization, similar to the implementation of cursor. By providing the AI with sufficient context, it can offer more accurate code review and fix suggestions.

Deployment

Deploy on Ubuntu 20.04:

git clone https://github.com/ZLMediaKit/Github-AI-Assistant.git
cd translation_issues
chmod +x ./run.sh
sudo ./run.sh

Deploy on other systems:

git clone https://github.com/ZLMediaKit/Github-AI-Assistant.git
cd translation_issues
# Install python3.11 or later
# Create a virtual environment
python3 -m venv venv
# Activate the virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt

Enable webhook server and auto-start on boot:

sudo ./run.sh auto_start

Usage

View help:

./run.sh --help

2023-12-30

View help for a specific command:

./run.sh trans_issues --help

2023-12-30

Set environment variables:

./run.sh update_env

[Note: If you are using the GEMINI-PRO model, keep OPENAI_API_KEY empty, as it will prioritize translation using the GPT4 model.]

Translate a specific issue:

./run.sh trans_issues --input-url https://github.com/your-org/your-repository/issues/1

[Note: If you haven't set environment variables in .env, you will need to specify parameters such as github-token, model_name and api_key]

./run.sh trans_issues --input-url https://github.com/your-org/your-repository/issues/1 --github-token ghp_xxx --model_name gemini/gemini-1.5-flash --api_key xxxx

Translate a specific discussion:

./run.sh trans_discussions --input-url https://github.com/your-org/your-repository/discussions/1

Translate a specific PR:

./run.sh trans_pr --input-url https://github.com/your-org/your-repository/pull/1

Batch translate all issues/discussions/pull requests of a specific repository:

# Translate issues, limit 10 translations per batch
./run.sh batch_trans --input-url https://github.com/your-org/your-repository --query-filter issue --query-limit 10
# Translate discussions, limit 10 translations per batch
./run.sh batch_trans --input-url https://github.com/your-org/your-repository --query-filter discussion --query-limit 10
# Translate pull requests, limit 10 translations per batch
./run.sh batch_trans --input-url https://github.com/your-org/your-repository --query-filter pr --query-limit 10

Use AI to review the specified PR or commit:

# Review PR
./run.sh review_pr --input-url https://github.com/ZLMediaKit/ZLMediaKit/pull/3758
# Review commit
./run.sh review_commit --input-url https://github.com/ZLMediaKit/ZLMediaKit/commit/e322db0a044fec82c66cc4e0b0daaa5e3b75b079

Use webhook

Start the GitHub webhook server:

./run.sh webhook start

After enabling the webhook server, you need to configure a webhook in GitHub. Please refer to this guide for configuration.

The Payload URL for the webhook is: http://your-ip:port/api/v1/hooks

How to Enable Code Review Based on Code Tree Segmentation and Vectorization

Currently, only Python and C/C++ code reviews are supported. If you need to review code in other languages, please extend the CodeElementAnalyzer class.

The current embedding model used is jinaai/jina-embeddings-v2-base-code, but you can choose other models according to your needs.

The current vector database used is milvus/milvus, but you can choose other databases according to your needs.

You can edit the EMBEDDING_MODEL and MILVUS_URI in the .env file to select your model and database.

EMBEDDING_MODEL=jinaai/jina-embeddings-v2-base-code
MILVUS_URI=milvus://

Then, you need to vectorize the codebase and build the index:

./run make_project_index --repo-url https://github.com/ZLMediaKit/ZLToolKit    

Once the project is vectorized and the index is built, code reviews will prioritize using the vectorized method. Other functionalities remain the same as regular code reviews, without any modifications needed.

However, please note that if it is for testing purposes, you do not need to set MILVUS_URI in the .env file, as it will automatically use the lite version of the vector database. For production environments, you must deploy the Milvus database and set MILVUS_URI.

About

The best AI assistant for your Github repository, it can not only help you automatically translate issues/discussions/pr/commit to the specified language, but also help you with code review, automatic code repair and other functions through AI models.您Github存储库的最佳AI助手, 它不但可以帮助您自动翻译issues/discussions/pr/commit到指定语言, 还可以通过AI模型帮助您进行代码审查, 代码自动修复等功能

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.3%
  • Shell 0.7%