mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
move to gpt-3.5-turbo-1106
This commit is contained in:
parent
6ebc142377
commit
fb07b784f6
8 changed files with 27 additions and 23 deletions
|
@ -53,10 +53,10 @@ class Coder:
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(
|
def create(
|
||||||
self,
|
self,
|
||||||
client,
|
|
||||||
main_model=None,
|
main_model=None,
|
||||||
edit_format=None,
|
edit_format=None,
|
||||||
io=None,
|
io=None,
|
||||||
|
client=None,
|
||||||
skip_model_availabily_check=False,
|
skip_model_availabily_check=False,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
|
@ -67,12 +67,13 @@ class Coder:
|
||||||
|
|
||||||
if not skip_model_availabily_check and not main_model.always_available:
|
if not skip_model_availabily_check and not main_model.always_available:
|
||||||
if not check_model_availability(io, client, main_model):
|
if not check_model_availability(io, client, main_model):
|
||||||
|
fallback_model = models.GPT35_1106
|
||||||
if main_model != models.GPT4:
|
if main_model != models.GPT4:
|
||||||
io.tool_error(
|
io.tool_error(
|
||||||
f"API key does not support {main_model.name}, falling back to"
|
f"API key does not support {main_model.name}, falling back to"
|
||||||
f" {models.GPT35_16k.name}"
|
f" {fallback_model.name}"
|
||||||
)
|
)
|
||||||
main_model = models.GPT35_16k
|
main_model = fallback_model
|
||||||
|
|
||||||
if edit_format is None:
|
if edit_format is None:
|
||||||
edit_format = main_model.edit_format
|
edit_format = main_model.edit_format
|
||||||
|
@ -163,7 +164,9 @@ class Coder:
|
||||||
|
|
||||||
if use_git:
|
if use_git:
|
||||||
try:
|
try:
|
||||||
self.repo = GitRepo(self.io, fnames, git_dname, aider_ignore_file)
|
self.repo = GitRepo(
|
||||||
|
self.io, fnames, git_dname, aider_ignore_file, client=self.client
|
||||||
|
)
|
||||||
self.root = self.repo.root
|
self.root = self.repo.root
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.repo = None
|
self.repo = None
|
||||||
|
@ -950,7 +953,8 @@ class Coder:
|
||||||
|
|
||||||
def check_model_availability(io, client, main_model):
|
def check_model_availability(io, client, main_model):
|
||||||
available_models = client.models.list()
|
available_models = client.models.list()
|
||||||
model_ids = sorted(model.id for model in available_models["data"])
|
dump(available_models)
|
||||||
|
model_ids = sorted(model.id for model in available_models)
|
||||||
if main_model.name in model_ids:
|
if main_model.name in model_ids:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -157,12 +157,13 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
||||||
default=False,
|
default=False,
|
||||||
help="Override to skip model availability check (default: False)",
|
help="Override to skip model availability check (default: False)",
|
||||||
)
|
)
|
||||||
|
default_3_model = models.GPT35_1106
|
||||||
core_group.add_argument(
|
core_group.add_argument(
|
||||||
"-3",
|
"-3",
|
||||||
action="store_const",
|
action="store_const",
|
||||||
dest="model",
|
dest="model",
|
||||||
const=models.GPT35_16k.name,
|
const=default_3_model.name,
|
||||||
help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)",
|
help=f"Use {default_3_model.name} model for the main chat (gpt-4 is better)",
|
||||||
)
|
)
|
||||||
core_group.add_argument(
|
core_group.add_argument(
|
||||||
"--voice-language",
|
"--voice-language",
|
||||||
|
@ -509,11 +510,11 @@ def main(argv=None, input=None, output=None, force_git_root=None):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
coder = Coder.create(
|
coder = Coder.create(
|
||||||
client,
|
main_model=main_model,
|
||||||
main_model,
|
edit_format=args.edit_format,
|
||||||
args.edit_format,
|
io=io,
|
||||||
io,
|
skip_model_availabily_check=args.skip_model_availability_check,
|
||||||
args.skip_model_availability_check,
|
client=client,
|
||||||
##
|
##
|
||||||
fnames=fnames,
|
fnames=fnames,
|
||||||
git_dname=git_dname,
|
git_dname=git_dname,
|
||||||
|
|
|
@ -4,6 +4,7 @@ from .openrouter import OpenRouterModel
|
||||||
|
|
||||||
GPT4 = Model.create("gpt-4")
|
GPT4 = Model.create("gpt-4")
|
||||||
GPT35 = Model.create("gpt-3.5-turbo")
|
GPT35 = Model.create("gpt-3.5-turbo")
|
||||||
|
GPT35_1106 = Model.create("gpt-3.5-turbo-1106")
|
||||||
GPT35_16k = Model.create("gpt-3.5-turbo-16k")
|
GPT35_16k = Model.create("gpt-3.5-turbo-16k")
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
|
@ -33,11 +33,11 @@ class Model:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def weak_model():
|
def weak_model():
|
||||||
return Model.create("gpt-3.5-turbo")
|
return Model.create("gpt-3.5-turbo-1106")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def commit_message_models():
|
def commit_message_models():
|
||||||
return [Model.create("gpt-3.5-turbo"), Model.create("gpt-3.5-turbo-16k")]
|
return [Model.weak_model()]
|
||||||
|
|
||||||
def token_count(self, messages):
|
def token_count(self, messages):
|
||||||
if not self.tokenizer:
|
if not self.tokenizer:
|
||||||
|
|
|
@ -55,6 +55,7 @@ class OpenAIModel(Model):
|
||||||
if self.is_gpt35():
|
if self.is_gpt35():
|
||||||
self.edit_format = "whole"
|
self.edit_format = "whole"
|
||||||
self.always_available = True
|
self.always_available = True
|
||||||
|
self.send_undo_reply = False
|
||||||
|
|
||||||
if self.name == "gpt-3.5-turbo-1106":
|
if self.name == "gpt-3.5-turbo-1106":
|
||||||
self.prompt_price = 0.001
|
self.prompt_price = 0.001
|
||||||
|
|
|
@ -7,12 +7,8 @@ cached_model_details = None
|
||||||
|
|
||||||
class OpenRouterModel(Model):
|
class OpenRouterModel(Model):
|
||||||
def __init__(self, client, name):
|
def __init__(self, client, name):
|
||||||
if name == "gpt-4":
|
if name.startswith("gpt-4") or name.startswith("gpt-3.5-turbo"):
|
||||||
name = "openai/gpt-4"
|
name = "openai/" + name
|
||||||
elif name == "gpt-3.5-turbo":
|
|
||||||
name = "openai/gpt-3.5-turbo"
|
|
||||||
elif name == "gpt-3.5-turbo-16k":
|
|
||||||
name = "openai/gpt-3.5-turbo-16k"
|
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.edit_format = edit_format_for_model(name)
|
self.edit_format = edit_format_for_model(name)
|
||||||
|
|
|
@ -110,9 +110,7 @@ class GitRepo:
|
||||||
raise OpenAIClientNotProvided
|
raise OpenAIClientNotProvided
|
||||||
|
|
||||||
if len(diffs) >= 4 * 1024 * 4:
|
if len(diffs) >= 4 * 1024 * 4:
|
||||||
self.io.tool_error(
|
self.io.tool_error("Diff is too large to generate a commit message.")
|
||||||
f"Diff is too large for {models.GPT35.name} to generate a commit message."
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
diffs = "# Diffs:\n" + diffs
|
diffs = "# Diffs:\n" + diffs
|
||||||
|
|
|
@ -12,6 +12,9 @@ class TestModels(unittest.TestCase):
|
||||||
model = Model.create("gpt-3.5-turbo-16k")
|
model = Model.create("gpt-3.5-turbo-16k")
|
||||||
self.assertEqual(model.max_context_tokens, 16 * 1024)
|
self.assertEqual(model.max_context_tokens, 16 * 1024)
|
||||||
|
|
||||||
|
model = Model.create("gpt-3.5-turbo-1106")
|
||||||
|
self.assertEqual(model.max_context_tokens, 16 * 1024)
|
||||||
|
|
||||||
model = Model.create("gpt-4")
|
model = Model.create("gpt-4")
|
||||||
self.assertEqual(model.max_context_tokens, 8 * 1024)
|
self.assertEqual(model.max_context_tokens, 8 * 1024)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue