/Github-AI-Assistant

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模型帮助您进行代码审查, 代码自动修复等功能

Primary LanguagePythonMIT LicenseMIT

Github AI Assistant

[GitHub issues]

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.

中文

Acknowledgements

This project references and utilizes some code from the ossrs/discussion-translation project. Special thanks to the original author for their work.

Here's the English translation of the content, maintaining the original format:

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

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