Skip to content

Commit 75c11ba

Browse files
authored
Merge pull request #29 from don7panic/feat/glm-4.7
fix: add file parameter alias for model compatibility
2 parents 008b651 + 7095174 commit 75c11ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

codewiki/src/be/agent_tools/str_replace_editor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ async def str_replace_editor(
710710
ctx: RunContext[CodeWikiDeps],
711711
working_dir: Literal["repo", "docs"],
712712
command: Literal["view", "create", "str_replace", "insert", "undo_edit"],
713-
path: str,
713+
path: Optional[str] = None,
714+
file: Optional[str] = None,
714715
file_text: Optional[str] = None,
715716
view_range: Optional[List[int]] = None,
716717
old_str: Optional[str] = None,
@@ -730,12 +731,18 @@ async def str_replace_editor(
730731
working_dir: The working directory to use. Choose `repo` to work with the repository files, or `docs` to work with the generated documentation files.
731732
command: The command to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.
732733
path: Path to file or directory, e.g. `./chat_core.md` or `./agents/`
734+
file: Alias for `path` parameter (for compatibility with some models)
733735
file_text: Required parameter of `create` command, with the content of the file to be created.
734736
view_range: Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.
735737
old_str: Required parameter of `str_replace` command containing the string in `path` to replace.
736738
new_str: Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.
737739
"""
738740

741+
# Handle both `path` and `file` parameters for model compatibility
742+
if path is None and file is None:
743+
return "Error: Either `path` or `file` parameter must be provided."
744+
if path is None:
745+
path = file
739746

740747
tool = EditTool(ctx.deps.registry, ctx.deps.absolute_docs_path)
741748
if working_dir == "docs":
@@ -746,7 +753,7 @@ async def str_replace_editor(
746753
# validate command
747754
if command != "view" and working_dir == "repo":
748755
return "The `view` command is the only allowed command when `working_dir` is `repo`."
749-
756+
750757
tool(
751758
command=command,
752759
path=absolute_path,

0 commit comments

Comments
 (0)