Fix: Correctly load built-in providers when using explicit 'provider' in ModelConfig#349
Open
siddikisahil47 wants to merge 4 commits intogoogle:mainfrom
Open
Fix: Correctly load built-in providers when using explicit 'provider' in ModelConfig#349siddikisahil47 wants to merge 4 commits intogoogle:mainfrom
siddikisahil47 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.