Update model fields immediately on save #1125
Open
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
profile_name
field ignored for Amazon Bedrock Chat Models in jupyter-ai Extension #1007.Fixes usage of model fields by respecting the updated values immediately on save (without requiring a restart).
Model fields are used to specify provider-specific keyword arguments directly from Jupyter AI's Settings UI. These include
Base API URL
for OpenAI,Region name
for Amazon Bedrock, etc.Demo
Screen.Recording.2024-11-27.at.10.33.12.AM.mov
Details for contributors
Fixes a bug introduced by Setting default model providers #421:
BaseProvider.get_model_parameters()
would return the fields set by the existingconfig.json
on init, instead of the user-specified overrides in theAiExtension.model_parameters
trait.ConfigManager
accidentally merging the existing config intoself.settings["model_parameters"]
instead of a deep copy of that dictionary.Fixes a bug introduced by Distinguish between completion and chat models #711: Model fields were not being returned at all from the dictionary returned by
ConfigManager.lm_provider_params
.config.json
on init still got passed to the LLM due to the bug introduced by Setting default model providers #421. Essentially, the bug introduced by Setting default model providers #421 "covered up" the bug introduced by Distinguish between completion and chat models #711. This explains why the issue was difficult to reproduce and why a restart fixed it.Makes the
allowed_providers
,blocked_providers
,allowed_models
,blocked_models
arguments toConfigManager
optional and default toNone
, as indicated by their type signatures.Adds unit test coverage for both aforementioned bugs.
Testing instructions
config.py
:deepcopy(self._defaults.get(config_key))
toself._defaults.get(config_key)
near line 240.**fields,
near line 475.pytest
, and verify that the 2 added tests fail. This asserts that the tests actually capture the bugs introduced by Setting default model providers #421 and Distinguish between completion and chat models #711.pytest
, and verify the 2 added tests now pass.