mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Pre-process file content to remove artifacts
This commit is contained in:
parent
766ead99dd
commit
114c850e4e
1 changed files with 11 additions and 1 deletions
|
|
@ -925,6 +925,16 @@ export class ClaudeDev {
|
|||
fileExists = await fileExistsAtPath(absolutePath)
|
||||
this.diffViewProvider.editType = fileExists ? "modify" : "create"
|
||||
}
|
||||
|
||||
// pre-processing newContent for cases where weaker models might add artifacts like markdown codeblock markers (deepseek/llama) or extra escape characters (gemini)
|
||||
if (newContent.startsWith("```")) {
|
||||
// this handles cases where it includes language specifiers like ```python ```js
|
||||
newContent = newContent.split("\n").slice(1).join("\n").trim()
|
||||
}
|
||||
if (newContent.endsWith("```")) {
|
||||
newContent = newContent.split("\n").slice(0, -1).join("\n").trim()
|
||||
}
|
||||
|
||||
const sharedMessageProps: ClaudeSayTool = {
|
||||
tool: fileExists ? "editedExistingFile" : "newFileCreated",
|
||||
path: getReadablePath(cwd, removeClosingTag("path", relPath)),
|
||||
|
|
@ -1596,7 +1606,7 @@ export class ClaudeDev {
|
|||
// stream did not complete tool call, add it as partial
|
||||
if (currentParamName) {
|
||||
// tool call has a parameter that was not completed
|
||||
currentToolUse.params[currentParamName] = accumulator.slice(currentParamValueStartIndex)
|
||||
currentToolUse.params[currentParamName] = accumulator.slice(currentParamValueStartIndex).trim()
|
||||
}
|
||||
toolUses.push(currentToolUse)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue