Beatrica
beatrica is an innovative Python package that utilizes Large Language Models (LLMs) such as OpenAI's GPT and MistralAI for automating code review processes. It provides insights by analyzing differences between the current active branch and a specified base branch, processing code changes, and generating reviews to improve code quality and collaboration.
Installation
Integrate cutting-edge code review automation into your workflow by installing beatrica using pip:
pip install beatrica
Configuring the API Key
For Beatrica to communicate with LLM services like OpenAI or MistralAI, an API key is required. You can provide this API key in two ways:
Using an Environment Variable
Set the API key as an environment variable before running Beatrica. This method is recommended for keeping your API key secure and not directly visible in command line history.
For Unix-like systems (Linux/macOS):
export LLM_API_KEY='your_api_key_here'
For Windows Command Prompt:
set LLM_API_KEY=your_api_key_here
For Windows PowerShell:
$env:LLM_API_KEY='your_api_key_here'
After setting the environment variable, you can run Beatrica without explicitly passing the API key in the command:
beatrica --base_branch=main --llm_type=openai
Using the Command Line Argument
If you prefer or need to, you can directly pass the API key as a command line argument. However, be mindful of security implications such as exposing your API key in shell history or logs.
beatrica --base_branch=main --llm_type=openai --api_key='your_api_key_here'
Choose the method that best suits your workflow and security practices.
Usage
Beatrica offers a CLI interface for specifying a base branch and comparing its differences with the current active branch, generating insightful reviews. Here are examples showcasing its usage with various configurations:
Basic Usage
To analyze code differences with the main branch using the default OpenAI's GPT-4 model, use:
beatrica --base_branch=main --llm_type=openai
This command compares the current active branch against the main branch.
Specifying LLM Type and Model
For a tailored review, specify the LLM (openai or mistralai) and model name:
beatrica --base_branch=main --llm_type=mistralai --model_name=mistral-large-latest
Advanced Configuration
Customize further by specifying the API key (from an environment variable or directly), the maximum tokens for the LLM response, and the output format:
beatrica --base_branch=develop --llm_type=openai --model_name=gpt-4-0125-preview --api_key=YOUR_API_KEY --max_tokens=1000 --output=beatrica_review.txt
Example Output
An example output of Beatrica reviewing changes between the current active branch and the main branch is:
Analyzing differences with base branch main using OpenAI GPT-4-0125-preview...
Tracking changes...
✅ Changes tracked.
✅ Found 2 changes.
Initializing language model...
Generating code embeddings...
✅ Embeddings generated.
Checking if Beatrica can review the changes...
✅ 1 changes found for review.
Starting the review process...
Reviewing changes ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:34
✅ Review process completed.
Aggregating reviews...
Aggregating reviews ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:20
✅ Reviews aggregated.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Commit ID ┃ Change Description ┃ Review ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ e08642828750dc15786c1166898fe30fa500c17c │ Added comment for test_generate_crsid_with_empty_first function │ The commit message "add comment for │
│ │ │ test_generate_crsid_with_empty_first" could be │
│ │ │ more descriptive to convey the purpose and │
│ │ │ importance of the added comment. A suggestion for │
│ │ │ a more informative commit message is "Explain test │
│ │ │ purpose for CRSID generation with empty first name │
│ │ │ in comments". This provides clear context on the │
│ │ │ change's significance. While adding a comment to │
│ │ │ the test function is a step in the right direction │
│ │ │ for code clarity, the comment itself could be more │
│ │ │ descriptive. It should explain not just what is │
│ │ │ being tested (generate_crsid with an empty first │
│ │ │ name), but also the expected outcome or behavior │
│ │ │ of the function under this condition. This would │
│ │ │ help in understanding the test's intention without │
│ │ │ diving into the implementation details. The test │
│ │ │ function "test_generate_crsid_with_empty_first()" │
│ │ │ could have a more descriptive name that reflects │
│ │ │ the expected behavior or outcome of the test, such │
│ │ │ as │
│ │ │ "test_crsid_generation_fails_with_empty_first_nam… │
│ │ │ or │
│ │ │ "test_crsid_generation_handles_empty_first_name_g… │
│ │ │ depending on the expected behavior. This makes it │
│ │ │ easier to understand the test's purpose at a │
│ │ │ glance. It is recommended to include input │
│ │ │ validation in the generate_crsid function to │
│ │ │ ensure that the arguments passed (first_name and │
│ │ │ last_name) are strings. This would prevent │
│ │ │ potential runtime errors and make the function │
│ │ │ more robust against incorrect usage. Considering │
│ │ │ the importance of ensuring uniqueness in CRSID │
│ │ │ generation, the function should include a │
│ │ │ mechanism to handle scenarios where uniqueness │
│ │ │ cannot be guaranteed. This could be due to │
│ │ │ multiple individuals sharing the same first and │
│ │ │ last names. Implementing a strategy to handle such │
│ │ │ cases gracefully would improve the function's │
│ │ │ reliability. Adding additional test cases to cover │
│ │ │ edge scenarios, such as both first and last names │
│ │ │ being empty or containing special characters or │
│ │ │ numbers, would enhance the test suite's │
│ │ │ comprehensiveness. This ensures that the function │
│ │ │ behaves as expected under various inputs. │
└──────────────────────────────────────────┴─────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────┘
Features
- Analyzes differences between the current active branch and a specified base branch.
- Integration with major LLMs for code review: OpenAI and MistralAI.
- Customizable for different base branches, LLMs, and output formats.
- Simplified CLI for ease of use.
Contributing
Contributions, issues, and
feature requests are welcome. For more information, check our issues page.
License
beatrica is made available under the GNU AFFERO GENERAL PUBLIC LICENSE.
Metadata
Release files for beatrica 2025.5.71632
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| beatrica-2025.5.71632.tar.gz | 22.9 kB | Without provenance | Details for beatrica-2025.5.71632.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| beatrica-2025.5.71632-py3-none-any.whl | Python 3 | none | any | Details for beatrica-2025.5.71632-py3-none-any.whl |
Total release size: 43.7 kB
Release files / beatrica-2025.5.71632.tar.gz
| Download URL | beatrica-2025.5.71632.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a1ca7483bc37dd628134d8c40b594d53f10770a29800bcea0b5ee2e3884f67b
|
|
BLAKE2b-256 checksum How to use checksums |
a84f6a80b8321d701f8b2a69cd49db4e12593bcb2abd75ad00747deb4720facc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Release files / beatrica-2025.5.71632-py3-none-any.whl
| Download URL | beatrica-2025.5.71632-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
daf60f44bbcc6ba66c81ba1523abd6696ae12cb11d09bfc5439e343f2f126baa
|
|
BLAKE2b-256 checksum How to use checksums |
d2bee5e128841625c49c7edb2a83ed47133c807d4ecd2deacb7a5b02f687625b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Security for beatrica 2025.5.71632
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.