Thank you for your interest in contributing to langchain-gradient! This document provides guidelines and instructions for contributing to this project.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Submitting Changes
- Issue Guidelines
- Pull Request Guidelines
- Release Process
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
- Python 3.9 or higher
- Poetry (for dependency management)
- Git
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/your-username/langchain-gradientai.git cd langchain-gradientai -
Install dependencies using Poetry:
poetry install --with dev,test,lint
-
Set up pre-commit hooks (optional but recommended):
poetry run pre-commit install
-
Configure your environment: Create a
.envfile with your DigitalOcean API key:DIGITALOCEAN_INFERENCE_KEY=your_access_key_here
- Create a new branch for each feature or bugfix
- Use descriptive branch names (e.g.,
feature/add-new-model,fix/streaming-issue) - Keep branches focused on a single change
git checkout -b feature/your-feature-nameThis project uses several tools to maintain code quality:
- Black for code formatting
- Ruff for linting and import sorting
- MyPy for type checking
- Codespell for spell checking
# Format all code
make format
# Format only changed files
make format_diff# Lint all code
make lint
# Lint only changed files
make lint_diff
# Lint specific packages
make lint_package # Lint langchain_gradient package
make lint_tests # Lint test files# Run MyPy type checking
poetry run mypy langchain_gradient# Check for spelling errors
make spell_check
# Fix spelling errors automatically
make spell_fixThe project has two types of tests:
- Unit Tests - Fast, isolated tests that don't require network access
- Integration Tests - Tests that interact with external APIs
# Run all unit tests
poetry run pytest --disable-socket --allow-unix-socket tests/unit_tests/
# Run tests for a specific file
poetry run pytest --disable-socket --allow-unix-socket tests/unit_tests/test_chat_models.py
# Run tests with verbose output
poetry run pytest --disable-socket --allow-unix-socket -v tests/unit_tests/
# Watch mode (re-runs tests on file changes)
poetry run ptw --snapshot-update --now . -- -vv tests/unit_tests/# Run integration tests (requires API key)
poetry run pytest tests/integration_tests/
# Run specific integration test file
poetry run pytest tests/integration_tests/test_chat_models.py- Write tests for new features and bug fixes
- Follow the existing test patterns in the
tests/directory - Use descriptive test names
- Include both positive and negative test cases
- Mock external API calls in unit tests
tests/
├── unit_tests/ # Unit tests (no network calls)
│ └── test_chat_models.py
└── integration_tests/ # Integration tests (with network calls)
├── test_chat_models.py
└── test_chat_model_streaming.py
- Write clear, descriptive commit messages
- Use the conventional commit format when possible:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions/changesrefactor:for code refactoringstyle:for formatting changes
Example:
feat: add support for new model endpoint
fix: resolve streaming response parsing issue
docs: update installation instructions
-
Ensure all checks pass:
make lint poetry run pytest --disable-socket --allow-unix-socket tests/unit_tests/ poetry run pytest tests/integration_tests/ # If applicable -
Update documentation if your changes affect user-facing functionality
-
Create a Pull Request:
- Use a clear, descriptive title
- Provide a detailed description of your changes
- Reference any related issues
- Include screenshots or examples if applicable
-
Respond to feedback promptly and make requested changes
When creating a PR, please include:
- Description: What changes were made and why
- Type of change: Bug fix, new feature, documentation, etc.
- Testing: How the changes were tested
- Breaking changes: Any breaking changes and migration steps
- Checklist: Confirm all requirements are met
- Check existing issues to avoid duplicates
- Search the documentation and README
- Try to reproduce the issue with the latest version
- Bug Report: Something isn't working as expected
- Feature Request: Suggest a new feature or enhancement
- Documentation: Improvements to documentation
- Question: Ask a question about usage or implementation
When reporting a bug, please include:
- Environment: Python version, OS, package version
- Steps to reproduce: Clear, numbered steps
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Error messages: Full error traceback if applicable
- Additional context: Any other relevant information
- Code follows the project's style guidelines
- All tests pass (unit and integration)
- Code is properly formatted and linted
- Documentation is updated if needed
- Commit messages are clear and descriptive
- Branch is up to date with main
Quick test commands:
# Run unit tests
poetry run pytest --disable-socket --allow-unix-socket tests/unit_tests/
# Run integration tests (if applicable)
poetry run pytest tests/integration_tests/
# Run linting
make lint- Automated checks must pass
- Code review by maintainers
- Testing on different environments if needed
- Approval from at least one maintainer
Releases are managed through the main LangChain repository. The process typically involves:
- Version bumping in
pyproject.toml - Updating changelog
- Creating a release tag
- Publishing to PyPI
- Documentation: Check the README and inline documentation
- Issues: Search existing issues or create a new one
- Discussions: Use GitHub Discussions for questions and ideas
# Setup
poetry install --with dev,test,lint
# Code quality
make format # Format code
make lint # Lint code
make spell_check # Check spelling
# Testing
poetry run pytest --disable-socket --allow-unix-socket tests/unit_tests/ # Run unit tests
poetry run pytest tests/integration_tests/ # Run integration tests
poetry run ptw --snapshot-update --now . -- -vv tests/unit_tests/ # Watch mode for tests
# Utilities
make check_imports # Check import structure
make help # Show all available commandsThank you for contributing to langchain-gradient! Your contributions help make this project better for everyone.
For questions about contributing, please open an issue or contact the maintainers.