Skip to content

Commit 05019df

Browse files
authored
Merge pull request #521 from SwapnilChand/main
[docs] revamping the UI and content of docs
2 parents 8ee0009 + 3404154 commit 05019df

21 files changed

+1044
-192
lines changed

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Kaizen takes a two-pronged approach to help you find and squash bugs, both befor
5757

5858
### Quick Start with Cloud Platform
5959

60-
1. Visit [https://beta.cloudcode.ai](https://beta.cloudcode.ai)
60+
1. Visit [https://kaizen.cloudcode.ai](https://kaizen.cloudcode.ai)
6161
2. Sign up for an account
6262
3. Follow the on-screen instructions to connect your repository
6363

@@ -92,7 +92,7 @@ Kaizen takes a two-pronged approach to help you find and squash bugs, both befor
9292
**Windows**
9393
```bash
9494
set PYTHONPATH=.
95-
poetry run python examples/basic/generate.py
95+
poetry run python examples/e2e_test/generate.py
9696
```
9797

9898

@@ -106,7 +106,7 @@ Kaizen takes a two-pronged approach to help you find and squash bugs, both befor
106106
**Windows**
107107
```bash
108108
set PYTHONPATH=.
109-
poetry run python examples/basic/execute.py
109+
poetry run python examples/e2e_test/execute.py
110110
```
111111

112112
or

Diff for: docs/pages/_meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"getting_started": "Getting Started",
44
"features": "Features",
55
"configuration": "Configuring Models",
6-
"cloud_platform": "Cloud Platform",
6+
"cloud_platform": "Web App",
77
"self_hosting_guide": "Self Hosting Guide",
88
"contributing": "Contributing",
99
"contact_us": "Contact Us"

Diff for: docs/pages/features/_meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"ui_review": "UI Review",
66
"e2e_testing": "End to End Testing",
77
"work_summary": "Work Summary"
8-
}
8+
}

Diff for: docs/pages/features/code_review.mdx

+144-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,100 @@
1-
## Code Review by Kaizen
1+
## Code Reviewer
22

3-
The Code Review is an AI-powered tool that automatically reviews and provides feedback on code changes in your pull requests (PRs). It helps streamline the code review process and ensures high code quality across your codebase.
3+
Automatically get reviews and feedback on code changes in your pull requests on GitHub.
4+
Streamline code reviews and ensure high code quality commit messages across your codebase.
45

56
![Code Review in Action](/code_review.gif)
67

7-
### How it Works
8+
### Key Features:
89

9-
1. **Diff Analysis**: When you create or update a pull request, the Code Review Bot analyzes the code changes (diff) and generates detailed feedback based on the modified code snippets.
10+
1. **Automated Code Analysis**: Analyzes code changes in pull requests and generates detailed feedback.
11+
12+
2. **Organized Feedback**: Provides review comments organized by topics and confidence levels.
13+
14+
3. **Interactive Reviews**: Allows engagement with the bot for clarification or additional context.
15+
16+
4. **PR Description Generation**: Automatically generates descriptive summaries of code changes.
17+
18+
5. **Continuous Learning**: Improves review quality over time based on user interactions.
19+
20+
## Usage Guide:
21+
22+
1. **Getting Started**: For a quickstart you can use the cloud hosted web application that we provide by following [this](../cloud_platform/getting_started). You can also choose to self host the Kaizen Github Bot locally by following the advanced guide [here](../self_hosting_guide).
23+
The next given steps explore the latter approach in details.
24+
2. **Create or Update a Pull Request**: The Kaizen Bot will automatically analyze the code changes and generate a review.
25+
3. **Review the Feedback**: The bot's feedback will be shared as a comment on your pull request, organized by topics and confidence levels.
26+
4. **Engage with the Bot**: You can interact with the bot, provide additional context, or request clarification on its feedback.
27+
5. **Iterate and Improve**: As you work with the bot, it will learn from your responses and improve the quality of its reviews over time.
28+
29+
### Example:
30+
31+
Here's a complete example to review a pull request:
32+
33+
```python
34+
from kaizen.reviewer.code_review import CodeReviewer
35+
from kaizen.generator.pr_description import PRDescriptionGenerator
36+
from kaizen.llms.provider import LLMProvider
37+
from github_app.github_helper.utils import get_diff_text, get_pr_files
38+
from github_app.github_helper.pull_requests import clean_keys, create_review_comments
39+
from kaizen.formatters.code_review_formatter import create_pr_review_text
40+
import json
41+
import logging
42+
43+
logging.basicConfig(level="DEBUG")
44+
45+
# Pull request information
46+
pr_diff = "https://github.com/Cloud-Code-AI/kaizen/pull/335.patch"
47+
pr_files = "https://api.github.com/repos/Cloud-Code-AI/kaizen/pulls/335/files"
48+
pr_title = "feat: updated the prompt to provide solution"
49+
50+
# Get diff text and PR files
51+
diff_text = get_diff_text(pr_diff, "")
52+
pr_files = get_pr_files(pr_files, "")
53+
54+
# Create CodeReviewer instance
55+
reviewer = CodeReviewer(llm_provider=LLMProvider())
56+
57+
# Review pull request
58+
review_data = reviewer.review_pull_request(
59+
diff_text=diff_text,
60+
pull_request_title=pr_title,
61+
pull_request_desc="",
62+
pull_request_files=pr_files,
63+
reeval_response=False,
64+
)
65+
66+
# Process review data
67+
topics = clean_keys(review_data.topics, "important")
68+
review_desc = create_pr_review_text(
69+
review_data.issues, code_quality=review_data.code_quality
70+
)
71+
comments, topics = create_review_comments(topics)
72+
73+
# Display results
74+
print(f"Raw Topics:\n{json.dumps(topics, indent=2)}\n")
75+
print(f"GENERATED REVIEW:\n{review_desc}")
76+
print(f"\nComment and topics:\n{json.dumps(comments, indent=2)},\n{topics}")
77+
78+
# Generate PR description
79+
print("---------------Generate desc-------------")
80+
pr_desc = PRDescriptionGenerator(llm_provider=LLMProvider())
81+
desc_data = pr_desc.generate_pull_request_desc(
82+
diff_text=None,
83+
pull_request_title=pr_title,
84+
pull_request_desc="",
85+
pull_request_files=pr_files,
86+
user="kaizen/example",
87+
)
88+
print(desc_data)
89+
```
90+
91+
### Supported Input:
92+
93+
- GitHub pull request information (diff, files, title, description)
94+
95+
## How it Works:
96+
97+
1. **Diff Analysis**: When you create or update a pull request, the Kaizen Bot analyzes the code changes (diff) and generates detailed feedback based on the modified code snippets.
1098

1199
2. **Organized Feedback**: The bot's feedback is organized into topics or categories like performance, security, code style, or documentation, making it easier to navigate and prioritize the comments.
12100

@@ -16,26 +104,64 @@ The Code Review is an AI-powered tool that automatically reviews and provides fe
16104

17105
5. **PR Description Generation**: The bot can generate a descriptive summary of the code changes, helping you better document your pull requests.
18106

19-
### Using the Code Review Bot
107+
![Code Review Process](/code_review_process.png)
108+
109+
You can find an example [here](https://github.com/Cloud-Code-AI/kaizen/tree/main/examples/code_review)
110+
111+
## API Reference:
112+
113+
### Class: CodeReviewer
114+
115+
#### Constructor
116+
117+
- `__init__(self, llm_provider: LLMProvider)`
118+
Initializes the CodeReviewer with the provided LLM provider.
119+
120+
#### Methods
121+
122+
##### review_pull_request
123+
124+
- `review_pull_request(self, diff_text: str, pull_request_title: str, pull_request_desc: str, pull_request_files: List[Dict], reeval_response: bool = False) -> ReviewData`
125+
Reviews a pull request and generates feedback.
126+
- Parameters:
127+
- `diff_text`: The diff text of the pull request.
128+
- `pull_request_title`: The title of the pull request.
129+
- `pull_request_desc`: The description of the pull request.
130+
- `pull_request_files`: List of files changed in the pull request.
131+
- `reeval_response`: Whether to re-evaluate the response.
132+
- Returns: ReviewData object containing the review results.
133+
134+
### Class: PRDescriptionGenerator
20135

21-
1. **Create or Update a Pull Request**: The Code Review Bot will automatically analyze the code changes and generate a review.
136+
#### Constructor
22137

23-
2. **Review the Feedback**: The bot's feedback will be shared as a comment on your pull request, organized by topics and confidence levels.
138+
- `__init__(self, llm_provider: LLMProvider)`
139+
Initializes the PRDescriptionGenerator with the provided LLM provider.
24140

25-
3. **Engage with the Bot**: You can interact with the bot, provide additional context, or request clarification on its feedback.
141+
#### Methods
26142

27-
4. **Iterate and Improve**: As you work with the bot, it will learn from your responses and improve the quality of its reviews over time.
143+
##### generate_pull_request_desc
28144

29-
### Benefits
145+
- `generate_pull_request_desc(self, diff_text: str, pull_request_title: str, pull_request_desc: str, pull_request_files: List[Dict], user: str) -> str`
146+
Generates a description for a pull request.
147+
- Parameters:
148+
- `diff_text`: The diff text of the pull request.
149+
- `pull_request_title`: The title of the pull request.
150+
- `pull_request_desc`: The existing description of the pull request.
151+
- `pull_request_files`: List of files changed in the pull request.
152+
- `user`: The user or context for generating the description.
153+
- Returns: A string containing the generated pull request description.
30154

31-
- **Improved Code Quality**: Catch potential issues and receive suggestions for improvements early in the development process.
32-
- **Time Savings**: Automated reviews reduce the time and effort required for manual code reviews.
33-
- **Consistent Standards**: Ensure consistent application of coding standards, best practices, and guidelines across your codebase.
34-
- **Knowledge Sharing**: The bot's reviews serve as a knowledge-sharing mechanism, providing insights that can benefit your entire development team.
155+
## Benefits:
35156

36-
### Limitations
157+
- Improved Code Quality
158+
- Time Savings
159+
- Consistent Standards
160+
- Knowledge Sharing
161+
- Automated Documentation
37162

38-
- **AI Limitations**: While advanced, the bot may still have limitations in understanding complex code or context-specific nuances.
39-
- **Human Oversight**: The bot's feedback should be considered a complementary tool to human code reviews, not a complete replacement.
163+
## Limitations:
40164

41-
With the Code Review Bot, you can streamline your code review process, maintain high code quality, and leverage the power of AI to enhance your development workflow.
165+
- AI Limitations: While advanced, the bot may still have limitations in understanding complex code or context-specific nuances.
166+
- Human Oversight: The bot's feedback should be considered a complementary tool to human code reviews, not a complete replacement.
167+
- GitHub API Limitations: Rate limits and authentication requirements may affect large-scale usage.

0 commit comments

Comments
 (0)