-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed conflict. * Updates for more stable generate feature (cherry picked from commit d9b26f5) * Refactored generate for better stability with all providers/models. (cherry picked from commit 608ed25) * Upgraded LangChain to 0.0.318 (cherry picked from commit 0d247fd) * Updated to use memory instead of chat history, fix for Bedrock Anthropic (cherry picked from commit 7c09863) * Allow to define block and allow lists for providers (#415) * Allow to block or allow-list providers by id * Add tests for block/allow-lists * Fix "No language model is associated with" issue This was appearing because the models which are blocked were not returned (correctly!) but the previous validation logic did not know that sometimes models may be missing for a valid reason even if there are existing settings for these. * Add docs for allow listing and block listing providers * Updated docs * Added an intro block to docs * Updated the docs --------- Co-authored-by: Piyush Jain <[email protected]> (cherry picked from commit 92dab10) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michał Krassowski <[email protected]>
- Loading branch information
1 parent
54c357b
commit 52c9339
Showing
13 changed files
with
283 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
packages/jupyter-ai-magics/jupyter_ai_magics/tests/test_utils.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import pytest | ||
from jupyter_ai_magics.utils import get_lm_providers | ||
|
||
KNOWN_LM_A = "openai" | ||
KNOWN_LM_B = "huggingface_hub" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"restrictions", | ||
[ | ||
{"allowed_providers": None, "blocked_providers": None}, | ||
{"allowed_providers": [], "blocked_providers": []}, | ||
{"allowed_providers": [], "blocked_providers": [KNOWN_LM_B]}, | ||
{"allowed_providers": [KNOWN_LM_A], "blocked_providers": []}, | ||
], | ||
) | ||
def test_get_lm_providers_not_restricted(restrictions): | ||
a_not_restricted = get_lm_providers(None, restrictions) | ||
assert KNOWN_LM_A in a_not_restricted | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"restrictions", | ||
[ | ||
{"allowed_providers": [], "blocked_providers": [KNOWN_LM_A]}, | ||
{"allowed_providers": [KNOWN_LM_B], "blocked_providers": []}, | ||
], | ||
) | ||
def test_get_lm_providers_restricted(restrictions): | ||
a_not_restricted = get_lm_providers(None, restrictions) | ||
assert KNOWN_LM_A not in a_not_restricted |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.