From 8fb4ab2be31d2516c53cafa84692f9b152980f1d Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 15 Jun 2023 06:26:16 -0700 Subject: [PATCH] cleaned up Model init --- aider/coder.py | 2 +- aider/models.py | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 1b021dadb..22434d18b 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -78,7 +78,7 @@ class Coder: else: self.console = Console(force_terminal=True, no_color=True) - main_model = models.get_model(main_model) + main_model = models.Model(main_model) if not main_model.is_always_available(): if not self.check_model_availability(main_model): if main_model != models.GPT4: diff --git a/aider/models.py b/aider/models.py index d8cdfa2d7..d7815fa0c 100644 --- a/aider/models.py +++ b/aider/models.py @@ -13,6 +13,11 @@ class Model: self.max_context_tokens = tokens * 1024 + if self.is_gpt4() or self.is_gpt35(): + return + + raise ValueError(f"Unsupported model: {name}") + def is_gpt4(self): return self.name.startswith("gpt-4") @@ -26,12 +31,3 @@ class Model: GPT4 = Model("gpt-4", 8) GPT35 = Model("gpt-3.5-turbo") GPT35_16k = Model("gpt-3.5-turbo-16k") - - -def get_model(name): - model = Model(name) - - if model.is_gpt4() or model.is_gpt35(): - return model - - raise ValueError(f"Unsupported model: {name}")