Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 1, 2023
1 parent d81338e commit fad17c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/jupyter-ai/jupyter_ai/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from jupyter_ai.chat_handlers.learn import Retriever
from jupyter_ai_magics.utils import get_em_providers, get_lm_providers
from jupyter_server.extension.application import ExtensionApp
from traitlets import List, Unicode, Dict
from traitlets import Dict, List, Unicode

from .chat_handlers import (
AskChatHandler,
Expand Down
39 changes: 26 additions & 13 deletions packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def common_cm_kwargs(config_path, schema_path):
"embeddings_provider_id": None,
"api_keys": None,
"fields": None,
}
},
}


Expand All @@ -63,8 +63,13 @@ def cm_kargs_with_defaults(config_path, schema_path):
"model_provider_id": "bedrock-chat:anthropic.claude-v1",
"embeddings_provider_id": "bedrock:amazon.titan-embed-text-v1",
"api_keys": {"OPENAI_API_KEY": "open-ai-key-value"},
"fields": {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}},
}
"fields": {
"bedrock-chat:anthropic.claude-v1": {
"credentials_profile_name": "default",
"region_name": "us-west-2",
}
},
},
}


Expand Down Expand Up @@ -148,11 +153,12 @@ def test_init_with_existing_config(
config_path=config_path,
schema_path=schema_path,
restrictions={"allowed_providers": None, "blocked_providers": None},
provider_defaults=None
provider_defaults=None,
)


def test_init_with_default_values(
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
):
"""
Test that the ConfigManager initializes with the expected default values.
Expand All @@ -163,18 +169,25 @@ def test_init_with_default_values(
schema_path (str): The path to the schema file.
"""
config_response = cm_with_defaults.get_config()
#assert config response
# assert config response
assert config_response.model_provider_id == "bedrock-chat:anthropic.claude-v1"
assert config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
assert (
config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
)
assert config_response.api_keys == ["OPENAI_API_KEY"]
assert config_response.fields == {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}}
assert config_response.fields == {
"bedrock-chat:anthropic.claude-v1": {
"credentials_profile_name": "default",
"region_name": "us-west-2",
}
}

del cm_with_defaults

log = logging.getLogger()
lm_providers = get_lm_providers()
em_providers = get_em_providers()
cm_with_defaults_override =ConfigManager(
cm_with_defaults_override = ConfigManager(
log=log,
lm_providers=lm_providers,
em_providers=em_providers,
Expand All @@ -184,10 +197,10 @@ def test_init_with_default_values(
provider_defaults={"model_provider_id": "bedrock-chat:anthropic.claude-v2"},
)

assert cm_with_defaults_override.get_config().model_provider_id == "bedrock-chat:anthropic.claude-v2"



assert (
cm_with_defaults_override.get_config().model_provider_id
== "bedrock-chat:anthropic.claude-v2"
)


def test_property_access_on_default_config(cm: ConfigManager):
Expand Down

0 comments on commit fad17c5

Please sign in to comment.