mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
wip
This commit is contained in:
parent
3465bd57d1
commit
2fce31209c
2 changed files with 87 additions and 9 deletions
|
@ -444,12 +444,77 @@ class Coder:
|
||||||
on_backoff=lambda details: print(f"Retry in {details['wait']} seconds."),
|
on_backoff=lambda details: print(f"Retry in {details['wait']} seconds."),
|
||||||
)
|
)
|
||||||
def send_with_retries(self, model, messages):
|
def send_with_retries(self, model, messages):
|
||||||
return openai.ChatCompletion.create(
|
_functions = [
|
||||||
|
dict(
|
||||||
|
name="replace_lines",
|
||||||
|
description="replace a block of contiguous lines with a new set of lines",
|
||||||
|
parameters=dict(
|
||||||
|
type="object",
|
||||||
|
required=["file_path", "original_lines", "updated_lines"],
|
||||||
|
properties=dict(
|
||||||
|
file_path=dict(
|
||||||
|
type="string",
|
||||||
|
description="path of file to edit",
|
||||||
|
),
|
||||||
|
original_lines=dict(
|
||||||
|
type="string",
|
||||||
|
description=(
|
||||||
|
"block of contiguous lines from the file (including newlines)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
updated_lines=dict(
|
||||||
|
type="string",
|
||||||
|
description=(
|
||||||
|
"block of contiguous lines from the file (including newlines)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
functions = [
|
||||||
|
dict(
|
||||||
|
name="write_file",
|
||||||
|
description="create or update a file",
|
||||||
|
parameters=dict(
|
||||||
|
type="object",
|
||||||
|
required=["explanation", "file_path", "file_content"],
|
||||||
|
properties=dict(
|
||||||
|
explanation=dict(
|
||||||
|
type="string",
|
||||||
|
description=(
|
||||||
|
"Explanation of the changes to be made to the code (markdown"
|
||||||
|
" format)"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
file_path=dict(
|
||||||
|
type="string",
|
||||||
|
description="Path of file to write",
|
||||||
|
),
|
||||||
|
file_content=dict(
|
||||||
|
type="string",
|
||||||
|
description="Content to write to the file",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
dump(functions)
|
||||||
|
|
||||||
|
res = openai.ChatCompletion.create(
|
||||||
model=model,
|
model=model,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
temperature=0,
|
temperature=0,
|
||||||
stream=True,
|
stream=False,
|
||||||
|
functions=functions,
|
||||||
)
|
)
|
||||||
|
dump(res)
|
||||||
|
msg = res.choices[0].message
|
||||||
|
dump(msg)
|
||||||
|
print(msg.content)
|
||||||
|
print(msg.function_call.arguments)
|
||||||
|
sys.exit()
|
||||||
|
return res
|
||||||
|
|
||||||
def send(self, messages, model=None, silent=False):
|
def send(self, messages, model=None, silent=False):
|
||||||
if not model:
|
if not model:
|
||||||
|
@ -482,10 +547,17 @@ class Coder:
|
||||||
assert False, "Exceeded context window!"
|
assert False, "Exceeded context window!"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
text = chunk.choices[0].delta.content
|
func = chunk.choices[0].delta.function_call
|
||||||
self.resp += text
|
dump(func)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
text = chunk.choices[0].delta.content
|
||||||
|
if text:
|
||||||
|
self.resp += text
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
if silent:
|
if silent:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -8,14 +8,20 @@ class FunctionPrompts(EditorPrompts):
|
||||||
Take requests for changes to the supplied code.
|
Take requests for changes to the supplied code.
|
||||||
If the request is ambiguous, ask questions.
|
If the request is ambiguous, ask questions.
|
||||||
|
|
||||||
Once you understand the request you MUST:
|
Once you understand the request you MUST use the `write_file` function to edit the files to make the needed changes.
|
||||||
1. Explain any needed changes.
|
|
||||||
2. Call functions to edit the code to make the needed changes.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
system_reminder = ""
|
system_reminder = """
|
||||||
|
ONLY return code using the `write_file` function.
|
||||||
|
NEVER return code outside the `write_file` function.
|
||||||
|
"""
|
||||||
|
|
||||||
files_content_prefix = "Here is the current content of the files:\n"
|
files_content_prefix = "Here is the current content of the files:\n"
|
||||||
files_no_full_files = "I am not sharing any files yet."
|
files_no_full_files = "I am not sharing any files yet."
|
||||||
|
|
||||||
redacted_edit_message = "No changes are needed."
|
redacted_edit_message = "No changes are needed."
|
||||||
|
|
||||||
|
repo_content_prefix = (
|
||||||
|
"Below here are summaries of other files! Do not propose changes to these *read-only*"
|
||||||
|
" files without asking me first.\n"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue