mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
catch ^c in commit() and use default commit message
This commit is contained in:
parent
cb63d15b52
commit
9d3ed13359
1 changed files with 20 additions and 21 deletions
17
coder.py
17
coder.py
|
@ -38,13 +38,15 @@ class Coder:
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.main_model = main_model
|
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
self.console = Console()
|
self.console = Console()
|
||||||
else:
|
else:
|
||||||
self.console = Console(force_terminal=True, no_color=True)
|
self.console = Console(force_terminal=True, no_color=True)
|
||||||
|
|
||||||
|
self.main_model = main_model
|
||||||
|
if main_model == 'gpt-3.5-turbo':
|
||||||
|
self.console.print(f'[red bold]This tool will almost certainly fail to work with {main_model}')
|
||||||
|
|
||||||
for fname in files:
|
for fname in files:
|
||||||
fname = Path(fname)
|
fname = Path(fname)
|
||||||
if not fname.exists():
|
if not fname.exists():
|
||||||
|
@ -289,6 +291,9 @@ class Coder:
|
||||||
import time
|
import time
|
||||||
from openai.error import RateLimitError
|
from openai.error import RateLimitError
|
||||||
|
|
||||||
|
self.resp = ""
|
||||||
|
interrupted = False
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
completion = openai.ChatCompletion.create(
|
completion = openai.ChatCompletion.create(
|
||||||
|
@ -303,8 +308,6 @@ class Coder:
|
||||||
print(f"Rate limit exceeded. Retrying in {retry_after} seconds.")
|
print(f"Rate limit exceeded. Retrying in {retry_after} seconds.")
|
||||||
time.sleep(retry_after)
|
time.sleep(retry_after)
|
||||||
|
|
||||||
interrupted = False
|
|
||||||
try:
|
|
||||||
if self.pretty and not silent:
|
if self.pretty and not silent:
|
||||||
self.show_send_output_color(completion)
|
self.show_send_output_color(completion)
|
||||||
else:
|
else:
|
||||||
|
@ -315,8 +318,6 @@ class Coder:
|
||||||
return self.resp, interrupted
|
return self.resp, interrupted
|
||||||
|
|
||||||
def show_send_output_plain(self, completion, silent):
|
def show_send_output_plain(self, completion, silent):
|
||||||
self.resp = ""
|
|
||||||
|
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
if chunk.choices[0].finish_reason not in (None, "stop"):
|
if chunk.choices[0].finish_reason not in (None, "stop"):
|
||||||
dump(chunk.choices[0].finish_reason)
|
dump(chunk.choices[0].finish_reason)
|
||||||
|
@ -331,8 +332,6 @@ class Coder:
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
def show_send_output_color(self, completion):
|
def show_send_output_color(self, completion):
|
||||||
self.resp = ""
|
|
||||||
|
|
||||||
with Live(vertical_overflow="scroll") as live:
|
with Live(vertical_overflow="scroll") as live:
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
if chunk.choices[0].finish_reason not in (None, "stop"):
|
if chunk.choices[0].finish_reason not in (None, "stop"):
|
||||||
|
@ -463,7 +462,7 @@ class Coder:
|
||||||
commit_message = commit_message.strip().strip('"').strip()
|
commit_message = commit_message.strip().strip('"').strip()
|
||||||
|
|
||||||
if interrupted:
|
if interrupted:
|
||||||
raise KeyboardInterrupt
|
commit_message = 'Saving dirty files before chat'
|
||||||
|
|
||||||
if prefix:
|
if prefix:
|
||||||
commit_message = prefix + commit_message
|
commit_message = prefix + commit_message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue