Add unified provider interface with string-based initialization
Summary
- Adds a unified string-based provider interface with
from_providerfunction for simplified initialization of LLM clients - Automatically selects appropriate default modes for each provider
- Comprehensive error handling with helpful error messages
- Full test coverage and documentation including a blog post
TODOs before merging
- [ ] Add additional test cases for the remaining providers beyond OpenAI
- [ ] Consider adding the Provider enum to the auto_client imports for consistency
- [ ] Add integration examples showing the new string-based initialization
- [ ] Update all provider documentation to mention the new initialization method
- [ ] Add API documentation for from_provider in the API reference
Test plan
- Verify string parsing works correctly for all provider formats
- Ensure default modes are correctly applied
- Test error handling for missing dependencies and invalid provider strings
- Check that async/sync client creation works correctly
- Verify proper parameter passing to provider client functions
🤖 Generated with Claude Code
[!IMPORTANT] Introduces a unified provider interface with string-based initialization for LLM clients, including error handling and documentation updates.
- Behavior:
- Adds
from_providerfunction inauto_client.pyfor string-based initialization of LLM clients.- Supports synchronous and asynchronous clients with
async_clientparameter.- Automatically selects default modes for each provider.
- Handles errors for missing dependencies and invalid provider strings.
- Documentation:
- Updates
README.mdwith provider initialization examples.- Adds blog post
string-based-init.mddetailing the new interface.- Updates
index.mdindocs/integrationsto include new initialization method.- Tests:
- Adds
test_auto_client.pyto test provider parsing and error handling.- Updates
test_simple_type_fix.pyandtest_fizzbuzz_fix.pyfor Python version compatibility.- Misc:
- Adds
run.pyexample inexamples/automodeldemonstrating the new interface.- Updates
pyproject.tomlversion to1.8.0.This description was created by
for d7d0d7a4d382b1936f4cc2566271f891e037e099. You can customize this summary. It will automatically update as commits are pushed.
Deploying instructor-py with
Cloudflare Pages
| Latest commit: |
d7d0d7a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c0300b30.instructor-py.pages.dev |
| Branch Preview URL: | https://automodel.instructor-py.pages.dev |
Tests are passing here in CI
tests/test_auto_client.py .......................... [100%]
Only do literals if it's also unions with the default string.
We don't want to make people upgrade instructor just to use a new model.
Let's publish first and then fix docs afterwards.
This is blocking some stuff I want to do in instructor-classify