From 9b26eeb9eb7b115db0e6eb68e5e93d488ab54edf Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 20 Apr 2024 08:17:50 -0700 Subject: [PATCH] Added validate_environment=False to tests --- aider/models.py | 12 +++++++----- tests/test_coder.py | 2 +- tests/test_commands.py | 2 +- tests/test_editblock.py | 2 +- tests/test_models.py | 12 ++++++------ tests/test_repomap.py | 4 ++-- tests/test_wholefile.py | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/aider/models.py b/aider/models.py index 026ea35f1..672138446 100644 --- a/aider/models.py +++ b/aider/models.py @@ -132,7 +132,7 @@ class Model: max_chat_history_tokens = 1024 weak_model = None - def __init__(self, model, weak_model=None, require_model_info=True): + def __init__(self, model, weak_model=None, require_model_info=True, validate_environment=True): self.name = model # Are all needed keys/params available? @@ -141,11 +141,13 @@ class Model: keys_in_environment = res.get("keys_in_environment") if missing_keys: - res = f"To use model {model}, please set these environment variables:" - for key in missing_keys: - res += f"- {key}" - raise ModelEnvironmentError(res) + if validate_environment: + res = f"To use model {model}, please set these environment variables:" + for key in missing_keys: + res += f"- {key}" + raise ModelEnvironmentError(res) elif not keys_in_environment: + # https://github.com/BerriAI/litellm/issues/3190 print(f"Unable to check environment variables for model {model}") # Do we have the model_info? diff --git a/tests/test_coder.py b/tests/test_coder.py index 35cf0093c..f0c966fe8 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -15,7 +15,7 @@ from aider.utils import ChdirTemporaryDirectory, GitTemporaryDirectory class TestCoder(unittest.TestCase): def setUp(self): - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) def test_allowed_to_edit(self): with GitTemporaryDirectory(): diff --git a/tests/test_commands.py b/tests/test_commands.py index 1751a359d..1f3d4d908 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -23,7 +23,7 @@ class TestCommands(TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) def tearDown(self): os.chdir(self.original_cwd) diff --git a/tests/test_editblock.py b/tests/test_editblock.py index a0c36f072..3b61cefed 100644 --- a/tests/test_editblock.py +++ b/tests/test_editblock.py @@ -14,7 +14,7 @@ from aider.models import Model class TestUtils(unittest.TestCase): def setUp(self): - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) # fuzzy logic disabled v0.11.2-dev def __test_replace_most_similar_chunk(self): diff --git a/tests/test_models.py b/tests/test_models.py index d46a721db..50cb47243 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -5,22 +5,22 @@ from aider.models import Model class TestModels(unittest.TestCase): def test_max_context_tokens(self): - model = Model("gpt-3.5-turbo") + model = Model("gpt-3.5-turbo", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 16385) - model = Model("gpt-3.5-turbo-16k") + model = Model("gpt-3.5-turbo-16k", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 16385) - model = Model("gpt-3.5-turbo-1106") + model = Model("gpt-3.5-turbo-1106", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 16385) - model = Model("gpt-4") + model = Model("gpt-4", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 8 * 1024) - model = Model("gpt-4-32k") + model = Model("gpt-4-32k", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 32 * 1024) - model = Model("gpt-4-0613") + model = Model("gpt-4-0613", validate_environment=False) self.assertEqual(model.info["max_input_tokens"], 8 * 1024) diff --git a/tests/test_repomap.py b/tests/test_repomap.py index aa5b09f48..8e367aa29 100644 --- a/tests/test_repomap.py +++ b/tests/test_repomap.py @@ -10,7 +10,7 @@ from aider.utils import IgnorantTemporaryDirectory class TestRepoMap(unittest.TestCase): def setUp(self): - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) def test_get_repo_map(self): # Create a temporary directory with sample files for testing @@ -156,7 +156,7 @@ print(my_function(3, 4)) class TestRepoMapTypescript(unittest.TestCase): def setUp(self): - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) def test_get_repo_map_typescript(self): # Create a temporary directory with a sample TypeScript file diff --git a/tests/test_wholefile.py b/tests/test_wholefile.py index 575444105..9dd684f5a 100644 --- a/tests/test_wholefile.py +++ b/tests/test_wholefile.py @@ -18,7 +18,7 @@ class TestWholeFileCoder(unittest.TestCase): self.tempdir = tempfile.mkdtemp() os.chdir(self.tempdir) - self.GPT35 = Model("gpt-3.5-turbo") + self.GPT35 = Model("gpt-3.5-turbo", validate_environment=False) def tearDown(self): os.chdir(self.original_cwd)