Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# CodeDog 环境变量示例文件
# 复制此文件为 .env 并填入您的实际配置值

# ===== 平台配置 =====
# 选择一个平台: GitHub 或 GitLab

# GitHub 配置
GITHUB_TOKEN="your_github_personal_access_token"

# GitLab 配置
# 如果使用 GitLab 而不是 GitHub
# GITLAB_TOKEN="your_gitlab_personal_access_token"
# 对于自托管实例,修改为您的 GitLab URL
# GITLAB_URL="https://gitlab.com"

# ===== LLM 配置 =====
# 选择一种配置方式: OpenAI, Azure OpenAI, DeepSeek 或 MindConnect

# OpenAI 配置
# 标准 OpenAI API
OPENAI_API_KEY="your_openai_api_key"

# Azure OpenAI 配置
# 如果使用 Azure 的 OpenAI 服务
# AZURE_OPENAI="true"
# AZURE_OPENAI_API_KEY="your_azure_openai_api_key"
# AZURE_OPENAI_API_BASE="https://your-instance.openai.azure.com/"
# 可选,默认会使用一个较新的版本
# AZURE_OPENAI_API_VERSION="2023-05-15"
# 用于代码摘要和评审的 GPT-3.5 部署
# AZURE_OPENAI_DEPLOYMENT_ID="your_gpt35_deployment_name"
# 用于 PR 摘要的 GPT-4 部署
# AZURE_OPENAI_GPT4_DEPLOYMENT_ID="your_gpt4_deployment_name"

# DeepSeek 配置
# 如果使用 DeepSeek 模型
# DEEPSEEK_API_KEY="your_deepseek_api_key"
# DeepSeek 模型名称
DEEPSEEK_MODEL="deepseek-chat"
# DeepSeek API 基础 URL
DEEPSEEK_API_BASE="https://api.deepseek.com"
# DeepSeek 温度参数
DEEPSEEK_TEMPERATURE="0"
# DeepSeek 最大token数
DEEPSEEK_MAX_TOKENS="4096"
# DeepSeek top_p参数
DEEPSEEK_TOP_P="0.95"
# DeepSeek 超时时间(秒)
DEEPSEEK_TIMEOUT="60"
# DeepSeek R1 特定配置
DEEPSEEK_R1_API_BASE="https://api.deepseek.com"
DEEPSEEK_R1_MODEL="deepseek-reasoner"

# ===== 模型选择配置 =====
# 可选值: "gpt-3.5", "gpt-4o", "deepseek"
CODE_SUMMARY_MODEL="gpt-3.5"
PR_SUMMARY_MODEL="gpt-3.5"
CODE_REVIEW_MODEL="gpt-3.5"

# ===== 电子邮件通知配置 =====
# 启用电子邮件通知
EMAIL_ENABLED="false"
# 接收通知的邮箱,多个邮箱用逗号分隔
NOTIFICATION_EMAILS="your_email@example.com"

# SMTP 服务器配置
# 用于发送电子邮件通知
# Gmail SMTP 配置说明:
# 1. 必须在 Google 账户开启两步验证: https://myaccount.google.com/security
# 2. 创建应用专用密码: https://myaccount.google.com/apppasswords
# 3. 使用应用专用密码而非您的常规Gmail密码
# Gmail SMTP 服务器地址
SMTP_SERVER="smtp.gmail.com"
# Gmail SMTP 服务器端口
SMTP_PORT="587"
# 发送邮件的 Gmail 账户
SMTP_USERNAME="your_email@gmail.com"
# SMTP_PASSWORD 应该是应用专用密码,不是您的 Gmail 登录密码
SMTP_PASSWORD="your_app_specific_password"

# ===== 开发者评价配置 =====
# 默认包含的文件类型
DEV_EVAL_DEFAULT_INCLUDE=".py,.js,.java,.ts,.tsx,.jsx,.c,.cpp,.h,.hpp"
# 默认排除的文件类型
DEV_EVAL_DEFAULT_EXCLUDE=".md,.txt,.json,.lock,.gitignore"

# ===== 其他可选配置 =====
# 日志级别,可以是 DEBUG, INFO, WARNING, ERROR
LOG_LEVEL="INFO"
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Codedog leverages Large Language Models (LLMs) like GPT to automatically review
* **Platform Support**: Works with GitHub and GitLab.
* **Automated Code Review**: Uses LLMs to analyze code changes, provide feedback, and suggest improvements
* **Scoring System**: Evaluates code across multiple dimensions, including correctness, readability, and maintainability
* **Multiple LLM Support**: Works with OpenAI (including GPT-4o), Azure OpenAI, DeepSeek, and MindConnect R1 models (see [Models Guide](docs/models.md))
* **Multiple LLM Support**: Works with OpenAI (including GPT-4o), Azure OpenAI, DeepSeek, and DeepSeek R1 models (see [Models Guide](docs/models.md))
* **Email Notifications**: Sends code review reports via email (see [Email Setup Guide](docs/email_setup.md))
* **Commit-Triggered Reviews**: Automatically reviews code when commits are made (see [Commit Review Guide](docs/commit_review.md))
* **Developer Evaluation**: Evaluates a developer's code over a specific time period
Expand Down Expand Up @@ -108,9 +108,6 @@ OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# DEEPSEEK_MODEL="deepseek-r1"
# DEEPSEEK_R1_API_BASE="https://your-r1-endpoint"

# LLM (MindConnect R1 example)
# MINDCONNECT_API_KEY="your_mindconnect_api_key"

# Model selection (optional)
CODE_SUMMARY_MODEL="gpt-3.5"
PR_SUMMARY_MODEL="gpt-4"
Expand Down Expand Up @@ -141,7 +138,14 @@ The `README.md` in the project root (and `codedog/__init__.py`) contains a quick

4. **Run the Script**: Execute the script within the Poetry environment:
```bash
poetry run python run_codedog.py
# For GitHub PR review
poetry run python run_codedog.py pr "owner/repo" 123

# For GitLab MR review
poetry run python run_codedog.py pr "owner/repo" 123 --platform gitlab

# For GitLab MR review with custom GitLab instance
poetry run python run_codedog.py pr "owner/repo" 123 --platform gitlab --gitlab-url "https://your.gitlab.instance.com"
```

This will:
Expand All @@ -151,6 +155,30 @@ This will:
* Use the configured LLM to generate code review suggestions.
* Print a formatted Markdown report to the console.

## GitLab Integration

Codedog fully supports GitLab integration for reviewing merge requests. To use GitLab integration:

1. **Set up GitLab Token**: Generate a personal access token with `api` scope from your GitLab account settings.

2. **Configure Environment Variables**: Add the following to your `.env` file:
```
GITLAB_TOKEN="your_gitlab_personal_access_token"
GITLAB_URL="https://gitlab.com" # Or your self-hosted GitLab URL
```

3. **Run GitLab MR Review**: Use the following command to review a GitLab merge request:
```bash
python run_codedog.py pr "owner/repo" 123 --platform gitlab
```

Replace `owner/repo` with your GitLab project path and `123` with your merge request IID.

4. **Self-hosted GitLab**: If you're using a self-hosted GitLab instance, specify the URL:
```bash
python run_codedog.py pr "owner/repo" 123 --platform gitlab --gitlab-url "https://your.gitlab.instance.com"
```

## Running Tests

To ensure the package is working correctly after setup or changes:
Expand Down
11 changes: 9 additions & 2 deletions UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@
python run_codedog.py eval "开发者名称" --start-date YYYY-MM-DD --end-date YYYY-MM-DD
```

2. **审查PR**:
2. **审查PR/MR**:
```bash
# GitHub PR审查
python run_codedog.py pr "仓库名称" PR编号

# GitLab MR审查
python run_codedog.py pr "仓库名称" MR编号 --platform gitlab

# 自托管GitLab实例
python run_codedog.py pr "仓库名称" MR编号 --platform gitlab --gitlab-url "https://your.gitlab.instance.com"
```

3. **设置Git钩子**:
Expand All @@ -74,4 +81,4 @@
1. 实现更好的文本分块和处理,以处理大型代码差异
2. 针对不同文件类型的更专业评分标准
3. 进一步改进报告呈现,添加可视化图表
4. 与CI/CD系统的更深入集成
4. 与CI/CD系统的更深入集成
Loading
Loading