Thank you for your interest in contributing to LangStruct! We welcome contributions from everyone.
- Python 3.12+
- uv (recommended) or pip
-
Clone the repository
git clone https://github.com/langstruct-ai/langstruct.git cd langstruct -
Install dependencies
# With uv (recommended) uv sync --extra dev # Or with pip pip install -e ".[dev]"
-
Set up API keys for testing
# Get a free API key from aistudio.google.com export GOOGLE_API_KEY="your-key-here" # Or use OpenAI export OPENAI_API_KEY="your-key-here"
-
Set up pre-commit hooks (optional but recommended)
uv run pre-commit install
-
Run tests
uv run pytest
-
Create a new branch
git checkout -b feature/your-feature-name
-
Run the test suite
uv run pytest -v
We maintain high code quality standards:
-
Formatting: Use
blackandisortuv run black . uv run isort .
-
Type Checking: Use
mypyuv run mypy langstruct/
-
Testing: Write tests for new features
uv run pytest tests/
- Follow existing patterns: Look at similar code in the project
- Update docstrings: All public functions should have comprehensive docstrings
- Add tests: Include tests for new functionality
- Update examples: Add examples for new features when appropriate
-
Push your branch
git push origin feature/your-feature-name
-
Create a Pull Request with:
- Clear title describing the change
- Description of what you changed and why
- Links to any relevant issues
langstruct/
├── langstruct/ # Main source code
│ ├── api.py # Main LangStruct class
│ ├── core/ # Core extraction modules
│ ├── optimizers/ # DSPy optimization modules
│ ├── providers/ # LLM provider interfaces
│ └── visualization/ # HTML visualization tools
├── tests/ # Test suite
├── examples/ # Example scripts
└── docs/ # Documentation source
- Use the bug report template
- Include reproduction steps
- Provide error messages and logs
- Use the feature request template
- Explain the use case
- Consider implementation approach
- Fix typos, improve clarity
- Add examples and tutorials
- Update API documentation
- Bug fixes
- New features
- Performance improvements
- Test coverage improvements
# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_api.py
# Run with coverage
uv run pytest --cov=langstruct
# Run integration tests (requires API key)
uv run pytest -m integration- Place tests in
tests/directory - Use descriptive test names
- Test both success and error cases
- Mock external API calls for unit tests
- Use integration tests sparingly (they cost money)
cd docs
pnpm install
pnpm dev # Local development server
pnpm build # Build static site- Use clear, concise language
- Include code examples
- Test all code examples
- Follow existing structure and style
We follow these conventions:
- Line length: 88 characters (Black default)
- Imports: Use
isortfor consistent import ordering - Type hints: Required for all public functions
- Docstrings: Google style docstrings for all public functions
def extract_entities(text: str, schema: Type[Schema]) -> ExtractionResult:
"""Extract structured entities from text using the provided schema.
Args:
text: Input text to extract from
schema: Pydantic schema defining extraction structure
Returns:
ExtractionResult with entities and metadata
Raises:
ExtractionError: If extraction fails
"""
# Implementation here
passReleases are automated via GitHub Actions when tags are pushed:
- Update version in
pyproject.toml - Update
CHANGELOG.md - Create and push tag:
git tag v0.1.1 && git push origin v0.1.1
- GitHub Issues: For bugs and feature requests
- Discussions: For questions and general discussion
This project follows the Contributor Covenant Code of Conduct.
Thank you for contributing to LangStruct! 🚀