Fix: Correctly load built-in providers when using explicit 'provider' in ModelConfig#349
Fix: Correctly load built-in providers when using explicit 'provider' in ModelConfig#349siddikisahil47 wants to merge 4 commits intogoogle:mainfrom
Conversation
|
I think this is essentially the same as #331 . |
|
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
1 similar comment
|
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
|
Your branch is 1 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
|
Your branch is 6 commits behind git fetch origin main
git merge origin/main
git pushNote: Enable "Allow edits by maintainers" to allow automatic updates. |
Description
Fixes a crash in
_create_model_with_schemawhere built-in providers were not loaded whenModelConfigwas initialized with an explicitproviderargument.Previously,
providers.load_builtins_once()andproviders.load_plugins_once()were only called inside theelseblock — meaning they were skipped whenconfig.providerwas set. This caused provider resolution to fail with anInferenceConfigError.Root cause (in
langextract/factory.py,_create_model_with_schema):Fix:
This aligns
_create_model_with_schemawithcreate_model, which already handles this correctly (lines 142-149).Reproduction:
Error before fix:
After fix: Provider resolves successfully ✅
Fixes #320
Bug fix
How Has This Been Tested?
Added a new unit test file
tests/factory_provider_loading_test.py:Test details:
ModelConfigwith explicitprovider="openai"._create_model_with_schemaand asserts that we do not get a"No provider found matching"error.Code style verified with
./autoformat.sh(all pre-commit hooks passed).Checklist:
pylintover the affected code.