live view of multiple file edits

This commit is contained in:
Paul Gauthier 2023-06-21 20:49:16 -07:00
parent 3a38e176d1
commit f187cf0346
2 changed files with 20 additions and 24 deletions

View file

@ -729,7 +729,7 @@ class Coder:
return None, err return None, err
def parse_partial_args(self): def parse_partial_args(self):
dump(self.partial_response_function_call) # dump(self.partial_response_function_call)
data = self.partial_response_function_call.get("arguments") data = self.partial_response_function_call.get("arguments")
if not data: if not data:

View file

@ -2,7 +2,7 @@ import os
from aider import diffs from aider import diffs
from ..dump import dump from ..dump import dump # noqa: F401
from .base_coder import Coder from .base_coder import Coder
from .func_prompts import FunctionPrompts from .func_prompts import FunctionPrompts
@ -11,10 +11,10 @@ class FunctionCoder(Coder):
functions = [ functions = [
dict( dict(
name="write_file", name="write_file",
description="create or update a file", description="create or update one or more files",
parameters=dict( parameters=dict(
type="object", type="object",
required=["explanation", "files_to_update"], required=["explanation", "files"],
properties=dict( properties=dict(
explanation=dict( explanation=dict(
type="string", type="string",
@ -23,17 +23,17 @@ class FunctionCoder(Coder):
" tense, markdown format)" " tense, markdown format)"
), ),
), ),
files_to_update=dict( files=dict(
type="array", type="array",
items=dict( items=dict(
type="object", type="object",
required=["file_path", "file_content"], required=["path", "content"],
properties=dict( properties=dict(
file_path=dict( path=dict(
type="string", type="string",
description="Path of file to write", description="Path of file to write",
), ),
file_content=dict( content=dict(
type="string", type="string",
description="Content to write to the file", description="Content to write to the file",
), ),
@ -59,32 +59,28 @@ class FunctionCoder(Coder):
def modify_incremental_response(self): def modify_incremental_response(self):
args = self.parse_partial_args() args = self.parse_partial_args()
dump(args)
if not args: if not args:
return return
path = args.get("file_path")
explanation = args.get("explanation") explanation = args.get("explanation")
content = args.get("file_content") files = args.get("files", [])
res = "" res = ""
if explanation: if explanation:
res += f"{explanation}\n" res += f"{explanation}\n\n"
if not path: for file_upd in files:
return res path = file_upd.get("path")
if not path:
continue
content = file_upd.get("content")
if not content:
continue
if path: res += path + ":\n"
if res: res += self.live_diffs(path, content)
res += "\n"
res += path + "\n"
if not content:
return res
res += self.live_diffs(path, content)
return res return res
def live_diffs(self, fname, content): def live_diffs(self, fname, content):