Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into cedarscript
Browse files Browse the repository at this point in the history
  • Loading branch information
elifarley committed Nov 13, 2024
2 parents 7fe6713 + 7d0b67f commit 3b00d0d
Show file tree
Hide file tree
Showing 13 changed files with 443 additions and 97 deletions.
2 changes: 1 addition & 1 deletion aider/coders/architect_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ArchitectPrompts(CoderPrompts):
DO NOT show the entire updated function/file/etc!
Always reply in the same language as the change request.
Always reply to the user in {language}.
"""

example_messages = []
Expand Down
2 changes: 1 addition & 1 deletion aider/coders/ask_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class AskPrompts(CoderPrompts):
main_system = """Act as an expert code analyst.
Answer questions about the supplied code.
Always reply to the user in the same language they are using.
Always reply to the user in {language}.
"""

example_messages = []
Expand Down
7 changes: 6 additions & 1 deletion aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ def fmt_system_prompt(self, prompt):
platform=platform_text
)

if self.chat_language:
language = self.chat_language
else:
language = "in the same language they are using"

prompt = prompt.format(
fence=self.fence,
lazy_prompt=lazy_prompt,
Expand All @@ -964,6 +969,7 @@ def fmt_system_prompt(self, prompt):
final_remarks=self.gpt_prompts.final_remarks,
shell_cmd_prompt=shell_cmd_prompt,
shell_cmd_reminder=shell_cmd_reminder,
language=language,
)
return prompt

Expand Down Expand Up @@ -1599,7 +1605,6 @@ def calculate_and_show_tokens_and_cost(self, messages, completion=None):
completion.usage, "cache_creation_input_tokens"
):
self.message_tokens_sent += prompt_tokens
self.message_tokens_sent += cache_hit_tokens
self.message_tokens_sent += cache_write_tokens
else:
self.message_tokens_sent += prompt_tokens
Expand Down
2 changes: 1 addition & 1 deletion aider/coders/editblock_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EditBlockPrompts(CoderPrompts):
Take requests for changes to the supplied code.
If the request is ambiguous, ask questions.
Always reply to the user in the same language they are using.
Always reply to the user in {language}.
Once you understand the request you MUST:
Expand Down
2 changes: 1 addition & 1 deletion aider/coders/udiff_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UnifiedDiffPrompts(CoderPrompts):
Take requests for changes to the supplied code.
If the request is ambiguous, ask questions.
Always reply to the user in the same language they are using.
Always reply to the user in {language}.
For each file that needs to be changed, write out the changes similar to a unified diff like `diff -U0` would produce.
"""
Expand Down
2 changes: 1 addition & 1 deletion aider/coders/wholefile_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class WholeFilePrompts(CoderPrompts):
Take requests for changes to the supplied code.
If the request is ambiguous, ask questions.
Always reply to the user in the same language they are using.
Always reply to the user in {language}.
{lazy_prompt}
Once you understand the request you MUST:
Expand Down
18 changes: 14 additions & 4 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,25 @@ def make_new_repo(git_root, io):


def setup_git(git_root, io):
try:
cwd = Path.cwd()
except OSError:
cwd = None

repo = None

if git_root:
repo = git.Repo(git_root)
elif Path.cwd() == Path.home():
try:
repo = git.Repo(git_root)
except ANY_GIT_ERROR:
pass
elif cwd == Path.home():
io.tool_warning("You should probably run aider in a directory, not your home dir.")
return
elif io.confirm_ask("No git repo found, create one to track aider's changes (recommended)?"):
git_root = str(Path.cwd().resolve())
elif cwd and io.confirm_ask(
"No git repo found, create one to track aider's changes (recommended)?"
):
git_root = str(cwd.resolve())
repo = make_new_repo(git_root, io)

if not repo:
Expand Down
46 changes: 35 additions & 11 deletions aider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ class ModelSettings:
"diff-fenced",
use_repo_map=True,
),
ModelSettings(
"vertex_ai/gemini-pro-experimental",
"diff-fenced",
use_repo_map=True,
),
ModelSettings(
"gemini/gemini-1.5-flash-exp-0827",
"whole",
Expand Down Expand Up @@ -710,6 +715,15 @@ class ModelSettings:
use_temperature=False,
streaming=False,
),
ModelSettings(
"openrouter/qwen/qwen-2.5-coder-32b-instruct",
"diff",
weak_model_name="openrouter/qwen/qwen-2.5-coder-32b-instruct",
editor_model_name="openrouter/qwen/qwen-2.5-coder-32b-instruct",
editor_edit_format="editor-diff",
use_repo_map=True,
reminder="user",
),
]


Expand Down Expand Up @@ -770,16 +784,20 @@ def get_model_from_cached_json_db(self, model):
return dict()

def get_model_info(self, model):
if not litellm._lazy_module:
info = self.get_model_from_cached_json_db(model)
if info:
return info
cached_info = self.get_model_from_cached_json_db(model)

# If all else fails, do it the slow way...
try:
return litellm.get_model_info(model)
except Exception:
return dict()
litellm_info = None
if litellm._lazy_module or not cached_info:
try:
litellm_info = litellm.get_model_info(model)
except Exception as ex:
if "model_prices_and_context_window.json" not in str(ex):
print(str(ex))

if litellm_info:
return litellm_info

return cached_info


model_info_manager = ModelInfoManager()
Expand Down Expand Up @@ -1049,8 +1067,14 @@ def register_litellm_models(model_fnames):
continue

try:
with open(model_fname, "r") as model_def_file:
model_def = json5.load(model_def_file)
data = Path(model_fname).read_text()
if not data.strip():
continue
model_def = json5.loads(data)
if not model_def:
continue

# only load litellm if we have actual data
litellm._load_litellm()
litellm.register_model(model_def)
except Exception as e:
Expand Down
75 changes: 0 additions & 75 deletions aider/resources/model-metadata.json

This file was deleted.

Loading

0 comments on commit 3b00d0d

Please sign in to comment.