Added improved editing support for command-r-plus

This commit is contained in:
Paul Gauthier 2024-04-20 09:59:56 -07:00
parent b882d5db4c
commit cd838901d1
4 changed files with 34 additions and 5 deletions

View file

@ -312,7 +312,10 @@ separators = "|".join([HEAD, DIVIDER, UPDATED])
split_re = re.compile(r"^((?:" + separators + r")[ ]*\n)", re.MULTILINE | re.DOTALL)
missing_filename_err = f"Bad/missing filename. Filename should be alone on the line before {HEAD}"
missing_filename_err = (
"Bad/missing filename. The filename must be alone on the line before the opening fence"
" {fence[0]}"
)
def strip_filename(filename, fence):
@ -325,6 +328,9 @@ def strip_filename(filename, fence):
if filename.startswith(start_fence):
return
filename = filename.rstrip(":")
filename = filename.strip("`")
return filename
@ -363,12 +369,12 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE):
if current_filename:
filename = current_filename
else:
raise ValueError(missing_filename_err)
raise ValueError(missing_filename_err.format(fence=fence))
except IndexError:
if current_filename:
filename = current_filename
else:
raise ValueError(missing_filename_err)
raise ValueError(missing_filename_err.format(fence=fence))
current_filename = filename

View file

@ -65,6 +65,8 @@ class WholeFileCoder(Coder):
fname_source = "block"
fname = lines[i - 1].strip()
fname = fname.strip("*") # handle **filename.py**
fname = fname.rstrip(":")
fname = fname.strip("`")
# Did gpt prepend a bogus dir? It especially likes to
# include the path/to prefix from the one-shot example in

View file

@ -117,6 +117,14 @@ MODEL_SETTINGS = [
use_repo_map=True,
send_undo_reply=True,
),
# Cohere
ModelSettings(
"command-r-plus",
"whole",
weak_model_name="command-r-plus",
use_repo_map=True,
send_undo_reply=True,
),
]
@ -187,6 +195,8 @@ class Model:
return # <--
# use the defaults
if self.edit_format == "diff":
self.use_repo_map = True
def __str__(self):
return self.name