<h1 align="center">
<a href="https://prompts.chat">
Join us in enhancing the Instructor library with evals, report issues, and submit pull requests on GitHub. Collaborate and contribute!
Sign in to like and favorite skills
We welcome contributions to Instructor! This page covers the different ways you can help improve the library.
Evals help us monitor the quality of both the OpenAI models and the Instructor library. To contribute:
Evals are run weekly, and results are tracked to monitor performance over time.
If you encounter a bug or problem, please file an issue on GitHub with:
response_model you're usingmessages you sentmodel you're usingWe welcome pull requests! Here's the process:
UV is a fast Python package installer and resolver that makes development easier.
Install UV (official method):
# macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows PowerShell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Install Project in Development Mode:
# Clone the repository git clone https://github.com/YOUR-USERNAME/instructor.git cd instructor # Install with development dependencies uv pip install -e ".[dev,docs]"
Adding New Dependencies:
# Add a regular dependency uv pip install some-package # Install a specific version uv pip install "some-package>=1.0.0,<2.0.0"
Common UV Commands:
# Update UV itself uv self update # Create a requirements file uv pip freeze > requirements.txt
Poetry provides comprehensive dependency management and packaging.
Install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
Install Dependencies:
# Clone the repository git clone https://github.com/YOUR-USERNAME/instructor.git cd instructor # Install with development dependencies poetry install --with dev,docs
Working with Poetry:
# Activate virtual environment poetry shell # Run a command in the virtual environment poetry run pytest # Add a dependency poetry add package-name # Add a development dependency poetry add --group dev package-name
Instructor uses optional dependencies to support different LLM providers. Provider-specific utilities live in the
instructor/utils directory. To add a new provider:
Add Dependencies to pyproject.toml:
[project.optional-dependencies] # Add your provider my-provider = ["my-provider-sdk>=1.0.0,<2.0.0"] [dependency-groups] # Mirror in dependency groups my-provider = ["my-provider-sdk>=1.0.0,<2.0.0"]
Create Provider Client:
instructor/clients/client_myprovider.pyfrom_myprovider function that patches the provider's clientAdd Tests: Create tests in
tests/llm/test_myprovider/
Document Installation:
# Installation command for your provider uv pip install "instructor[my-provider]" # or with poetry poetry install --with my-provider
Create Provider Utilities and Handlers:
instructor/utils/myprovider.py with reask and handle_* helpersMYPROVIDER_HANDLERS mapping Mode values to these functionsRegister the Provider:
instructor/utils/providers.py with your provider enum valueget_provider detection for your base URLUpdate
:process_response.py
mode_handlersWrite Documentation:
docs/integrations/ for your providermkdocs.yml to include your new pagegit clone https://github.com/YOUR-USERNAME/instructor.git cd instructor git remote add upstream https://github.com/instructor-ai/instructor.git
git checkout -b feature/your-feature-name
# Run tests pytest tests/ -k 'not llm and not openai' # Skip LLM tests for faster local dev # Commit changes git add . git commit -m "Your descriptive commit message"
git fetch upstream git rebase upstream/main git push origin feature/your-feature-name
The
scripts/ directory contains utility scripts that help maintain code quality and documentation. These scripts are integrated into pre-commit hooks and can also be run manually.
make_clean.py - Markdown File CleanerCleans markdown files by removing special whitespace characters and replacing em dashes with regular dashes.
# Clean all markdown files python scripts/make_clean.py # Preview changes without modifying files python scripts/make_clean.py --dry-run
check_blog_excerpts.py - Blog Post Excerpt ValidatorEnsures all blog posts contain the
<!-- more --> tag for proper excerpt handling.
# Check all blog posts python scripts/check_blog_excerpts.py
make_sitemap.py - Enhanced Documentation Sitemap GeneratorGenerates an enhanced sitemap (
sitemap.yaml) with AI-powered content analysis and cross-link suggestions.
# Generate sitemap with default settings python scripts/make_sitemap.py # Customize settings python scripts/make_sitemap.py \ --root-dir docs \ --output-file sitemap.yaml \ --max-concurrency 10
Requirements for sitemap generation:
OPENAI_API_KEY environment variable)openai, typer, rich, tenacity, pyyamlThese scripts run automatically during the commit process:
docs/You can run scripts manually for testing or one-time operations:
# Test markdown cleaning python scripts/make_clean.py --dry-run # Check blog excerpts python scripts/check_blog_excerpts.py # Generate fresh sitemap python scripts/make_sitemap.py
For detailed documentation on each script, see the
scripts/README.md file in the project repository.
Cursor is an AI-powered code editor that can help you contribute to Instructor.
Getting Started with Cursor:
.cursor/rules/Using Cursor Rules:
new-features-planning: Helps plan and structure new featuressimple-language: Guidelines for writing clear documentationdocumentation-sync: Ensures documentation stays in sync with code changesCreating PRs with Cursor:
# Use GitHub CLI to create the PR gh pr create -t "Your feature title" -b "Description of your changes" -r jxnl,ivanleomk
This PR was written by [Cursor](https://cursor.sh) to your PR descriptionBenefits of Using Cursor:
We use the following tools to maintain code quality:
# Install pre-commit hooks pip install pre-commit pre-commit install
Key style guidelines:
When reviewing code or writing commit messages, we use conventional comments to make feedback clearer:
<label>: <subject> <description>
Common labels:
Examples:
suggestion: use a validator for this field This would ensure the value is always properly formatted. question: why not use async processing here? I'm curious if this would improve performance. fix: correct the parameter type It should be an OpenAI client instance, not a string.
This format helps everyone understand the purpose and importance of each comment. Visit conventionalcomments.org to learn more.
We use conventional commit messages to make our project history clear and generate automated changelogs. A conventional commit has this structure:
<type>[optional scope]: <description> [optional body] [optional footer]
feat(openai): add streaming response support fix(anthropic): resolve tool calling response format docs: update installation instructions test(evals): add new recursive schema test cases
For breaking changes, add an exclamation mark before the colon:
feat(api)!: change return type of from_openai function
Using conventional commits helps automatically generate release notes and makes the project history easier to navigate.
For more details, see the Conventional Commits specification.
Documentation improvements are highly valued:
docs/ directorymkdocs.yml in the right sectionmkdocs serve to preview changes locallyExample of a good documentation code block:
# Complete example with imports import instructor from pydantic import BaseModel # Define your model class Person(BaseModel): name: str age: int # Create the patched client client = instructor.from_provider("openai/gpt-5-nano") # Use the model person = client.create( model="gpt-3.5-turbo", response_model=Person, messages=[ {"role": "user", "content": "Extract: John Doe is 25 years old"} ] ) print(person.name) # "John Doe" print(person.age) # 25
When working on documentation, these resources may be helpful:
mkdocs serve: Preview documentation locally. Install dependencies from
requirements-doc.txt first.
hl_lines in Code Blocks: Highlight specific lines in a code block to draw attention:
```python hl_lines="2 3" def example(): # This line is highlighted # This line is also highlighted return "normal line" ```
Admonitions: Create styled callout boxes for important information:
!!! note "Optional Title" This is a note admonition. !!! warning This is a warning.
For more documentation features, check the MkDocs Material documentation.
Thank you for your contributions to Instructor!