architect/editor

This commit is contained in:
Paul Gauthier 2024-09-26 16:10:19 -07:00
parent b551e29de3
commit eb21cf2830
23 changed files with 337 additions and 337 deletions

View file

@ -1,11 +1,11 @@
from .architect_coder import ArchitectCoder
from .ask_coder import AskCoder
from .base_coder import Coder
from .editblock_coder import EditBlockCoder
from .editblock_fenced_coder import EditBlockFencedCoder
from .editor_editblock_coder import EditorEditBlockCoder
from .editor_whole_coder import EditorWholeFileCoder
from .help_coder import HelpCoder
from .junior_editblock_coder import JuniorEditBlockCoder
from .junior_whole_coder import JuniorWholeFileCoder
from .senior_coder import SeniorCoder
from .udiff_coder import UnifiedDiffCoder
from .wholefile_coder import WholeFileCoder
@ -20,7 +20,7 @@ __all__ = [
WholeFileCoder,
UnifiedDiffCoder,
# SingleWholeFileFunctionCoder,
SeniorCoder,
JuniorEditBlockCoder,
JuniorWholeFileCoder,
ArchitectCoder,
EditorEditBlockCoder,
EditorWholeFileCoder,
]

View file

@ -180,10 +180,10 @@ class Coder:
output += ", infinite output"
lines.append(output)
if self.edit_format == "senior":
if self.edit_format == "architect":
output = (
f"Junior model: {main_model.junior_model.name} with"
f" {main_model.junior_edit_format} edit format"
f"Editor model: {main_model.editor_model.name} with"
f" {main_model.editor_edit_format} edit format"
)
lines.append(output)

View file

@ -1,7 +1,7 @@
from .editblock_coder import EditBlockCoder
from .junior_editblock_prompts import JuniorEditBlockPrompts
from .editor_editblock_prompts import EditorEditBlockPrompts
class JuniorEditBlockCoder(EditBlockCoder):
edit_format = "junior-diff"
gpt_prompts = JuniorEditBlockPrompts()
class EditorEditBlockCoder(EditBlockCoder):
edit_format = "editor-diff"
gpt_prompts = EditorEditBlockPrompts()

View file

@ -3,7 +3,7 @@
from .editblock_prompts import EditBlockPrompts
class JuniorEditBlockPrompts(EditBlockPrompts):
class EditorEditBlockPrompts(EditBlockPrompts):
main_system = """Act as an expert software developer who edits source code.
{lazy_prompt}
Describe each change with a *SEARCH/REPLACE block* per the examples below.

View file

@ -1,7 +1,7 @@
from .junior_whole_prompts import JuniorWholeFilePrompts
from .editor_whole_prompts import EditorWholeFilePrompts
from .wholefile_coder import WholeFileCoder
class JuniorWholeFileCoder(WholeFileCoder):
edit_format = "junior-whole"
gpt_prompts = JuniorWholeFilePrompts()
class EditorWholeFileCoder(WholeFileCoder):
edit_format = "editor-whole"
gpt_prompts = EditorWholeFilePrompts()

View file

@ -3,7 +3,7 @@
from .wholefile_prompts import WholeFilePrompts
class JuniorWholeFilePrompts(WholeFilePrompts):
class EditorWholeFilePrompts(WholeFilePrompts):
main_system = """Act as an expert software developer and make changes to source code.
{lazy_prompt}
Output a copy of each file that needs changes.

View file

@ -1,11 +1,11 @@
from .architect_prompts import ArchitectPrompts
from .ask_coder import AskCoder
from .base_coder import Coder
from .senior_prompts import SeniorPrompts
class SeniorCoder(AskCoder):
edit_format = "senior"
gpt_prompts = SeniorPrompts()
class ArchitectCoder(AskCoder):
edit_format = "architect"
gpt_prompts = ArchitectPrompts()
def reply_completed(self):
content = self.partial_response_content
@ -15,11 +15,11 @@ class SeniorCoder(AskCoder):
kwargs = dict()
# Use the junior_model from the main_model if it exists, otherwise use the main_model itself
junior_model = self.main_model.junior_model or self.main_model
# Use the editor_model from the main_model if it exists, otherwise use the main_model itself
editor_model = self.main_model.editor_model or self.main_model
kwargs["main_model"] = junior_model
kwargs["edit_format"] = self.main_model.junior_edit_format
kwargs["main_model"] = editor_model
kwargs["edit_format"] = self.main_model.editor_edit_format
kwargs["suggest_shell_commands"] = False
kwargs["map_tokens"] = 0
kwargs["total_cost"] = self.total_cost
@ -29,12 +29,12 @@ class SeniorCoder(AskCoder):
new_kwargs = dict(io=self.io, from_coder=self)
new_kwargs.update(kwargs)
junior_coder = Coder.create(**new_kwargs)
junior_coder.cur_messages = []
junior_coder.done_messages = []
junior_coder.show_announcements()
editor_coder = Coder.create(**new_kwargs)
editor_coder.cur_messages = []
editor_coder.done_messages = []
editor_coder.show_announcements()
junior_coder.run(with_message=content, preproc=False)
editor_coder.run(with_message=content, preproc=False)
self.move_back_cur_messages("I made those changes to the files.")
self.total_cost = junior_coder.total_cost
self.total_cost = editor_coder.total_cost

View file

@ -3,11 +3,11 @@
from .base_prompts import CoderPrompts
class SeniorPrompts(CoderPrompts):
main_system = """Act as an expert senior engineer and provide direction to your junior engineer.
class ArchitectPrompts(CoderPrompts):
main_system = """Act as an expert architect engineer and provide direction to your editor engineer.
Study the change request and the current code.
Describe how to modify the code to complete the request.
The junior engineer will rely solely on your instructions, so make them unambiguous and complete.
The editor engineer will rely solely on your instructions, so make them unambiguous and complete.
Explain all needed code changes clearly and completely, but concisely.
Just show the changes needed.