This commit is contained in:
Paul Gauthier 2023-05-09 00:14:13 -07:00
parent 437d735485
commit 71f992d1c7

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
import re import re
import readline import readline
@ -11,8 +12,6 @@ from rich.live import Live
from rich.text import Text from rich.text import Text
from rich.markdown import Markdown from rich.markdown import Markdown
from tqdm import tqdm
from pathlib import Path from pathlib import Path
import utils import utils
@ -25,6 +24,8 @@ from dump import dump
import prompts import prompts
openai.api_key = os.getenv("OPENAI_API_KEY") openai.api_key = os.getenv("OPENAI_API_KEY")
class Coder: class Coder:
fnames = dict() fnames = dict()
last_modified = 0 last_modified = 0
@ -113,6 +114,7 @@ class Coder:
for fname in self.fnames: for fname in self.fnames:
prompt += utils.quoted_file(fname) prompt += utils.quoted_file(fname)
return prompt return prompt
def get_input(self): def get_input(self):
if self.pretty: if self.pretty:
self.console.rule() self.console.rule()
@ -396,7 +398,9 @@ class Coder:
# first populating an empty file # first populating an empty file
new_content = after_text new_content = after_text
else: else:
new_content = utils.replace_most_similar_chunk(content, before_text, after_text) new_content = utils.replace_most_similar_chunk(
content, before_text, after_text
)
if not new_content: if not new_content:
self.console.print(f"[red]Failed to apply edit to {fname}") self.console.print(f"[red]Failed to apply edit to {fname}")
return return
@ -495,5 +499,6 @@ class Coder:
if __name__ == "__main__": if __name__ == "__main__":
from main import main from main import main
status = main() status = main()
sys.exit(status) sys.exit(status)