5.4 KiB
5.4 KiB
Contributing to AI-Writer
Thank you for your interest in contributing to AI-Writer! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Code of Conduct
- Getting Started
- Development Environment
- Coding Standards
- Pull Request Process
- Testing Guidelines
- Documentation
- Community
Code of Conduct
By participating in this project, you agree to abide by our Code of Conduct. Please read it before contributing.
Getting Started
Issues
- Check existing issues to see if your problem or idea has already been addressed.
- For bugs, create a new issue with a clear description, steps to reproduce, and relevant information about your environment.
- For feature requests, describe the feature, its benefits, and potential implementation approaches.
- Use issue templates when available.
Feature Branches
- Fork the repository and create a feature branch from
main. - Use descriptive branch names:
feature/your-feature-nameorfix/issue-description. - Keep branches focused on a single issue or feature.
Development Environment
Prerequisites
- Python 3.9 or higher
- Git
- A code editor (VS Code, PyCharm, etc.)
- Docker (optional, for containerized development)
Setup
-
Clone the repository:
git clone https://github.com/AJaySi/AI-Writer.git cd AI-Writer -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt -
Set up environment variables:
- Create a
.envfile in the project root - Add necessary API keys and configuration (see
.env.examplefor reference)
- Create a
-
Initialize the database:
python -c "from lib.database.db_manager import init_db; init_db()" -
Run the application:
streamlit run alwrity.py
Coding Standards
Style Guide
- Follow PEP 8 for Python code.
- Use 4 spaces for indentation (no tabs).
- Maximum line length is 100 characters.
- Use meaningful variable and function names.
Documentation
- Use Google-style docstrings for all modules, classes, and functions.
- Include type hints in function signatures.
- Keep comments up-to-date with code changes.
Example:
def generate_content(prompt: str, max_tokens: int = 100) -> str:
"""Generate content using the AI model.
Args:
prompt: The input prompt for content generation.
max_tokens: Maximum number of tokens to generate.
Returns:
The generated content as a string.
Raises:
ValueError: If the prompt is empty or max_tokens is negative.
"""
# Implementation...
Error Handling
- Use specific exception types rather than generic exceptions.
- Include meaningful error messages.
- Log exceptions with appropriate context.
Imports
- Group imports in the following order:
- Standard library imports
- Related third-party imports
- Local application/library specific imports
- Within each group, imports should be sorted alphabetically.
Pull Request Process
- Ensure your code follows the project's coding standards.
- Update documentation as necessary.
- Add or update tests to cover your changes.
- Ensure all tests pass.
- Submit a pull request with a clear description of the changes and any relevant issue numbers.
- Wait for review and address any feedback.
Commit Messages
Follow the Conventional Commits specification:
feat: A new featurefix: A bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code changes that neither fix bugs nor add featurestest: Adding or updating testschore: Changes to the build process or auxiliary tools
Example: feat: add support for Google Gemini models
Testing Guidelines
Writing Tests
- Write unit tests for all new functions and classes.
- Place tests in the
tests/directory, mirroring the package structure. - Use descriptive test names that explain what is being tested.
- Aim for at least 80% test coverage for new code.
Running Tests
# Run all tests
pytest
# Run specific tests
pytest tests/path/to/test_file.py
# Run with coverage
pytest --cov=lib
Documentation
Code Documentation
- Document all public modules, classes, and functions.
- Keep docstrings up-to-date with code changes.
- Use type hints consistently.
Project Documentation
- Update README.md with new features or changes.
- Update installation and usage instructions as needed.
- For significant changes, update the documentation in the
docs/directory.
Community
Communication Channels
- GitHub Issues: For bug reports and feature requests
- Discussions: For general questions and discussions
- Pull Requests: For code contributions
Recognition
All contributors will be recognized in the project's CONTRIBUTORS.md file.
Additional Resources
Thank you for contributing to AI-Writer!