- Install:
uv pip install -e ".[dev]"orpoetry install --with dev - Run tests:
uv run pytest tests/ - Run single test:
uv run pytest tests/path_to_test.py::test_name - Skip LLM tests:
uv run pytest tests/ -k 'not llm and not openai' - Type check:
uv run pyright - Lint:
uv run ruff check instructor examples tests - Format:
uv run ruff format instructor examples tests - Build docs:
uv run mkdocs serve(local) or./build_mkdocs.sh(production)
- Core:
instructor/- Pydantic-based structured outputs for LLMs - Base classes:
InstructorandAsyncInstructorinclient.py - Providers: Client files (
client_*.py) for OpenAI, Anthropic, Gemini, Cohere, etc. - Factory pattern:
from_provider()for automatic provider detection - DSL:
dsl/directory with Partial, Iterable, Maybe, Citation extensions - Key modules:
patch.py(patching),process_response.py(parsing),function_calls.py(schemas)
- Typing: Strict type annotations, use
BaseModelfor structured outputs - Imports: Standard lib → third-party → local
- Formatting: Ruff with Black conventions
- Error handling: Custom exceptions from
exceptions.py, Pydantic validation - Naming:
snake_casefunctions/variables,PascalCaseclasses - No mocking: Tests use real API calls
- Client creation: Always use
instructor.from_provider("provider_name/model_name")instead of provider-specific methods likefrom_openai(),from_anthropic(), etc.