Improved support for gpt-3.5-turbo-16k

This commit is contained in:
Paul Gauthier 2023-06-13 12:19:56 -07:00
parent e468763c7d
commit 25a28e6f9c
5 changed files with 19 additions and 20 deletions

View file

@ -59,8 +59,8 @@ You can find more chat transcripts on the [examples page](https://aider.chat/exa
## GPT-4 vs GPT-3.5 ## GPT-4 vs GPT-3.5
Aider now supports the brand new `gpt-3.5-turbo-16k` model. Aider now supports the brand new `gpt-3.5-turbo-16k` model.
You'll need to pull the latest build from GitHub for that to work. To use it, pull the latest build from GitHub and run `aider -3`.
For now, it just treats it like 3.5 with a bigger context window For now, aider just treats it like 3.5 with a bigger context window
(repo maps are disabled and it does not try and use a diff based output format). (repo maps are disabled and it does not try and use a diff based output format).
Aider supports `gpt-4`, `gpt-3.5-turbo` and `gpt-4-32k`. Aider supports `gpt-4`, `gpt-3.5-turbo` and `gpt-4-32k`.

View file

@ -79,14 +79,14 @@ class Coder:
self.console = Console(force_terminal=True, no_color=True) self.console = Console(force_terminal=True, no_color=True)
main_model = models.get_model(main_model) main_model = models.get_model(main_model)
if main_model != models.GPT35: if main_model not in models.GPT35_models:
if not self.check_model_availability(main_model): if not self.check_model_availability(main_model):
if main_model != models.GPT4: if main_model != models.GPT4:
self.io.tool_error(f"API key does not support {main_model.name}.") self.io.tool_error(f"API key does not support {main_model.name}.")
main_model = models.GPT35 main_model = models.GPT35_16k
self.main_model = main_model self.main_model = main_model
if main_model == models.GPT35: if main_model in models.GPT35_models:
self.io.tool_output( self.io.tool_output(
f"Using {main_model.name} (experimental): disabling ctags/repo-maps.", f"Using {main_model.name} (experimental): disabling ctags/repo-maps.",
) )
@ -107,7 +107,7 @@ class Coder:
self.io.tool_output("Not using git.") self.io.tool_output("Not using git.")
self.find_common_root() self.find_common_root()
if main_model != models.GPT35: if main_model in models.GPT4_models:
rm_io = io if self.verbose else None rm_io = io if self.verbose else None
self.repo_map = RepoMap( self.repo_map = RepoMap(
map_tokens, map_tokens,
@ -314,7 +314,7 @@ class Coder:
] ]
main_sys = self.gpt_prompts.main_system main_sys = self.gpt_prompts.main_system
if self.main_model != models.GPT35: if self.main_model in models.GPT4_models:
main_sys += "\n" + self.gpt_prompts.system_reminder main_sys += "\n" + self.gpt_prompts.system_reminder
messages = [ messages = [
@ -343,8 +343,8 @@ class Coder:
if edit_error: if edit_error:
return edit_error return edit_error
if self.main_model != models.GPT35 or not edited: if self.main_model in models.GPT4_models or not edited:
# Don't add assistant messages to the history if they contain "edits" # Don't add 3.5 assistant messages to the history if they contain "edits"
# Because those edits are actually fully copies of the file! # Because those edits are actually fully copies of the file!
# That wastes too much context window. # That wastes too much context window.
self.cur_messages += [dict(role="assistant", content=content)] self.cur_messages += [dict(role="assistant", content=content)]
@ -478,7 +478,7 @@ class Coder:
if self.pretty: if self.pretty:
show_resp = self.resp show_resp = self.resp
if self.main_model == models.GPT35: if self.main_model in models.GPT35_models:
try: try:
show_resp = self.update_files_gpt35(self.resp, mode="diff") show_resp = self.update_files_gpt35(self.resp, mode="diff")
except ValueError: except ValueError:
@ -782,9 +782,9 @@ class Coder:
return set(self.get_all_relative_files()) - set(self.get_inchat_relative_files()) return set(self.get_all_relative_files()) - set(self.get_inchat_relative_files())
def apply_updates(self, content): def apply_updates(self, content):
if self.main_model in (models.GPT4, models.GPT4_32k): if self.main_model in models.GPT4_models:
method = self.update_files_gpt4 method = self.update_files_gpt4
elif self.main_model == models.GPT35: elif self.main_model in models.GPT35_models:
method = self.update_files_gpt35 method = self.update_files_gpt35
else: else:
raise ValueError(f"apply_updates() doesn't support {self.main_model.name}") raise ValueError(f"apply_updates() doesn't support {self.main_model.name}")

View file

@ -183,7 +183,7 @@ class Commands:
"was reset and removed from git.\n" "was reset and removed from git.\n"
) )
if self.coder.main_model != models.GPT35: if self.coder.main_model in models.GPT4_models:
return prompts.undo_command_reply return prompts.undo_command_reply
def cmd_diff(self, args): def cmd_diff(self, args):

View file

@ -83,7 +83,7 @@ def main(args=None, input=None, output=None):
"-3", "-3",
action="store_const", action="store_const",
dest="model", dest="model",
const=models.GPT35.name, const=models.GPT35_16k.name,
help=f"Use {models.GPT35.name} model for the main chat (not advised)", help=f"Use {models.GPT35.name} model for the main chat (not advised)",
) )
parser.add_argument( parser.add_argument(

View file

@ -27,15 +27,14 @@ class Model_GPT35_16k:
max_context_tokens = 16 * 1024 max_context_tokens = 16 * 1024
GPT35 = Model_GPT35_16k() GPT35_16k = Model_GPT35_16k()
GPT35_models = [GPT35, GPT35_16k]
GPT4_models = [GPT4, GPT4_32k]
def get_model(name): def get_model(name):
models = [ models = GPT35_models + GPT4_models
GPT4_32k,
GPT4,
GPT35,
]
for model in models: for model in models:
if model.name == name: if model.name == name: