Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] API Reference and more UI Changes #522

Merged
merged 7 commits into from
Sep 10, 2024
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
7 changes: 7 additions & 0 deletions docs/pages/_app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../styles/styles.css';

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}

export default MyApp;
5 changes: 3 additions & 2 deletions docs/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"index": "Introduction",
"getting_started": "Getting Started",
"index": "Kaizen",
"initial_setup_guide": "Initial Setup Guide",
"features": "Features",
"configuration": "Configuring Models",
"cloud_platform": "Web App",
"api_reference": "API Reference",
"self_hosting_guide": "Self Hosting Guide",
"contributing": "Contributing",
"contact_us": "Contact Us"
Expand Down
203 changes: 203 additions & 0 deletions docs/pages/api_reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
This reference documents every object and method available in Kaizen’s SDK and API.

For a step-by-step guide on how to use Kaizen, check out the [Getting Started](../getting_started).

## Code Reviewer

### Class: CodeReviewer

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`
Initializes the CodeReviewer with the provided LLM provider.

#### Methods

##### review_pull_request

- `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`
Reviews a pull request and generates feedback.
- Parameters:
- `diff_text`: The diff text of the pull request.
- `pull_request_title`: The title of the pull request.
- `pull_request_desc`: The description of the pull request.
- `pull_request_files`: List of files changed in the pull request.
- `reeval_response`: Whether to re-evaluate the response.
- Returns: ReviewData object containing the review results.

### Class: PRDescriptionGenerator

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`
Initializes the PRDescriptionGenerator with the provided LLM provider.

#### Methods

##### generate_pull_request_desc

- `generate_pull_request_desc(self, diff_text: str, pull_request_title: str, pull_request_desc: str, pull_request_files: List[Dict], user: str) -> str`
Generates a description for a pull request.
- Parameters:
- `diff_text`: The diff text of the pull request.
- `pull_request_title`: The title of the pull request.
- `pull_request_desc`: The existing description of the pull request.
- `pull_request_files`: List of files changed in the pull request.
- `user`: The user or context for generating the description.
- Returns: A string containing the generated pull request description.

## Unit Test generator


### Class: UnitTestGenerator

#### Constructor

- `__init__(self, verbose=False)`
Initializes the UnitTestGenerator with optional verbosity setting.

#### Methods

##### generate_tests_from_dir

- `generate_tests_from_dir(self, dir_path: str, output_path: str = None)`
Generates unit tests for all supported files in a given directory.
- Parameters:
- `dir_path`: Path of the directory containing source files.
- `max_critique`: Maximum number of critique iterations.
- `output_path`: (Optional) Custom output path for generated tests.
- `verbose`: Enable verbose logging.
- `enable_critique`: Enable AI critique and improvement of generated tests.
- Returns: A tuple containing an empty dictionary and llm usage statistics.

##### generate_tests

- `generate_tests(self, file_path: str, content: str = None, max_critique: int = 3, output_path: str = None, verbose: bool = False, enable_critique: bool = False)`
Generates unit tests for a given file with various configuration options.
- Parameters:
- `file_path`: Path of the file relative to the project root.
- `content`: (Optional) File content.
- `max_critique`: Maximum number of critique iterations.
- `output_path`: (Optional) Custom output path for generated tests.
- `verbose`: Enable verbose logging.
- `enable_critique`: Enable AI critique and improvement of generated tests.
- Returns: A tuple containing an empty dictionary and llm usage statistics.

##### run_tests

- `run_tests(self) -> Dict`
Runs the generated unit tests and returns the results.



## Code Scanner

### Class: CodeScanner

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`
Initializes the CodeScanner with the provided LLM provider.

#### Methods

##### review_code

- `review_code(self, file_data: str, user: str) -> ReviewData`
Performs a code review on a single file.
- Parameters:
- `file_data`: Content of the file to be reviewed.
- `user`: Username or project identifier.
- Returns: ReviewData object containing the review results.

##### review_code_dir

- `review_code_dir(self, dir_path: str, reevaluate: bool = False, user: str) -> ReviewData`
Performs a code review on all files in a directory.
- Parameters:
- `dir_path`: Path to the directory containing the files to be reviewed.
- `reevaluate`: Whether to reevaluate previously scanned files.
- `user`: Username or project identifier.
- Returns: ReviewData object containing the review results for all files.

## UI Reviewer
### Class: UIReviewer

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`:
Initializes the UI Reviewer with the provided LLM provider.

#### Methods

##### generate_ui_review

- `generate_ui_review(self, url: str = None, html_content: str = None) -> Dict`
Performs a UI review on a given URL or HTML code.
- Parameters:
- `url`: URL of the web page to be reviewed.
- `html_code`: HTML code to be reviewed.
- Returns: A dictionary containing the review results.

## End to End Test Generator

### Class: E2ETestGenerator

#### Constructor

- `__init__(self)`
Initializes the E2ETestGenerator.

#### Methods

##### generate_e2e_tests

- `generate_e2e_tests(self, url: str) -> Tuple[List[Dict], Dict]`
Generates E2E UI tests for the given URL.
- Parameters:
- `url`: URL of the web application to test.
- Returns: A tuple containing a list of generated tests and LLM usage statistics.

##### run_tests

- `run_tests(self) -> Dict`
Runs the generated E2E UI tests.
- Returns: A dictionary containing test execution results.

## Work Summary Generator

### Class: WorkSummaryGenerator

#### Constructor

- `__init__(self)`
Initializes the WorkSummaryGenerator.

#### Methods

##### generate_work_summaries

- `generate_work_summaries(self, file_diffs: List[Dict], user: str) -> Dict`
Generates a work summary from the provided file diffs.
- Parameters:
- `file_diffs`: List of dictionaries containing file diff information.
- `user`: Username or identifier for the user generating the summary.
- Returns: A dictionary containing the generated summary and other relevant information.

##### generate_twitter_post

- `generate_twitter_post(self, summary: str, user: str) -> Tuple[str, Dict]`
Generates a Twitter post based on the work summary.
- Parameters:
- `summary`: The generated work summary.
- `user`: Username or identifier for the user generating the post.
- Returns: A tuple containing the generated Twitter post and LLM usage statistics.

##### generate_linkedin_post

- `generate_linkedin_post(self, summary: str, user: str) -> Tuple[str, Dict]`
Generates a LinkedIn post based on the work summary.
- Parameters:
- `summary`: The generated work summary.
- `user`: Username or identifier for the user generating the post.
- Returns: A tuple containing the generated LinkedIn post and LLM usage statistics.
3 changes: 0 additions & 3 deletions docs/pages/cloud_platform/_meta.json

This file was deleted.

10 changes: 5 additions & 5 deletions docs/pages/feature_request.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

We welcome feature requests from our users, as they help us improve our product and provide a better experience for everyone. If you have an idea for a new feature or an improvement to an existing one, please follow the steps below to submit a feature request.

## Step 1: Check Existing Requests
## Check Existing Requests

Before creating a new feature request, we recommend checking the existing ones in our [GitHub Discussions](https://github.com/Cloud-Code-AI/kaizen/discussions) to see if your idea has already been suggested. If you find a similar request, you can upvote it or add your thoughts to the existing discussion.

## Step 2: Create a New Discussion
## Create a New Discussion

If your feature request is unique, you can create a new discussion by following these steps:

Expand All @@ -21,15 +21,15 @@ If your feature request is unique, you can create a new discussion by following
- Mockups, diagrams, or examples (if applicable)
- Any additional context or information that could be helpful

## Step 3: Engage with the Community
## Engage with the Community

Once you've created your feature request, others in the community can view, comment, and react to it. We encourage you to engage with the community, answer questions, and provide additional details or clarifications as needed.

## Step 4: Wait for Review and Feedback
## Wait for Review and Feedback

Our team regularly reviews the feature requests in the discussions. We may ask for additional information, provide feedback, or share our plans regarding the implementation of the feature. Please be patient, as we carefully evaluate each request and prioritize them based on various factors.

## Step 5: Stay Informed
## Stay Informed

We will update the discussion with any progress or decisions made regarding your feature request. If your request is accepted for implementation, we will provide updates on the development timeline and release plans.

Expand Down
88 changes: 22 additions & 66 deletions docs/pages/features/code_review.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Streamline code reviews and ensure high code quality commit messages across your

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

### Key Features:
### Key Features

1. **Automated Code Analysis**: Analyzes code changes in pull requests and generates detailed feedback.

Expand All @@ -17,7 +17,23 @@ Streamline code reviews and ensure high code quality commit messages across your

5. **Continuous Learning**: Improves review quality over time based on user interactions.

## Usage Guide:
### How it Works

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.

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.

3. **Confidence Levels**: Each review comment includes a confidence level (critical, high, medium, low), indicating the perceived importance or severity of the issue.

4. **Contextual Information**: The reviews provide context-specific details like file names, line numbers, code snippets, and explanations for the suggested changes.

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

![Code Review Process](/code_review_process.png)

You can find an example [here](https://github.com/Cloud-Code-AI/kaizen/tree/main/examples/code_review)

## Usage Guide

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).
The next given steps explore the latter approach in details.
Expand All @@ -26,7 +42,7 @@ The next given steps explore the latter approach in details.
4. **Engage with the Bot**: You can interact with the bot, provide additional context, or request clarification on its feedback.
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.

### Example:
### Example

Here's a complete example to review a pull request:

Expand Down Expand Up @@ -88,79 +104,19 @@ desc_data = pr_desc.generate_pull_request_desc(
print(desc_data)
```

### Supported Input:
### Supported Input

- GitHub pull request information (diff, files, title, description)

## How it Works:

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.

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.

3. **Confidence Levels**: Each review comment includes a confidence level (critical, high, medium, low), indicating the perceived importance or severity of the issue.

4. **Contextual Information**: The reviews provide context-specific details like file names, line numbers, code snippets, and explanations for the suggested changes.

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

![Code Review Process](/code_review_process.png)

You can find an example [here](https://github.com/Cloud-Code-AI/kaizen/tree/main/examples/code_review)

## API Reference:

### Class: CodeReviewer

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`
Initializes the CodeReviewer with the provided LLM provider.

#### Methods

##### review_pull_request

- `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`
Reviews a pull request and generates feedback.
- Parameters:
- `diff_text`: The diff text of the pull request.
- `pull_request_title`: The title of the pull request.
- `pull_request_desc`: The description of the pull request.
- `pull_request_files`: List of files changed in the pull request.
- `reeval_response`: Whether to re-evaluate the response.
- Returns: ReviewData object containing the review results.

### Class: PRDescriptionGenerator

#### Constructor

- `__init__(self, llm_provider: LLMProvider)`
Initializes the PRDescriptionGenerator with the provided LLM provider.

#### Methods

##### generate_pull_request_desc

- `generate_pull_request_desc(self, diff_text: str, pull_request_title: str, pull_request_desc: str, pull_request_files: List[Dict], user: str) -> str`
Generates a description for a pull request.
- Parameters:
- `diff_text`: The diff text of the pull request.
- `pull_request_title`: The title of the pull request.
- `pull_request_desc`: The existing description of the pull request.
- `pull_request_files`: List of files changed in the pull request.
- `user`: The user or context for generating the description.
- Returns: A string containing the generated pull request description.

## Benefits:
## Benefits

- Improved Code Quality
- Time Savings
- Consistent Standards
- Knowledge Sharing
- Automated Documentation

## Limitations:
## Limitations

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