Closed as not planned
Closed as not planned
Description
The current flat structure with individual client_*.py
files has become difficult to maintain as we add more providers. We should reorganize into a proper provider package structure.
Current problems:
- Flat directory with many provider-specific files cluttering the root namespace
- Related provider code is scattered across
client_*.py
andprocess_response.py
- No clear interface that providers must implement
- Difficult to discover which functionality is supported by which provider
Proposed solution:
instructor/
├── providers/
│ ├── __init__.py # Provider registry and common utilities
│ ├── base.py # Provider interface/protocol
│ ├── oai_provider.py # OpenAI implementation (avoid name conflict)
│ ├── claude.py # Anthropic implementation
│ └── ... # Other providers
Each provider module would contain:
- Factory functions (e.g.,
from_openai
) - Provider-specific response handlers (moved from
process_response.py
) - Provider-specific validation logic (mode support, etc.)
- Provider-specific utility functions
- Structured comments documenting supported features
Implementation steps:
- Create
providers/
directory with placeholder__init__.py
andbase.py
- Move each
client_*.py
file into corresponding provider module with non-conflicting names - Move provider-specific handlers from
process_response.py
to provider modules - Update imports throughout codebase
- Update type annotations to reflect new structure