mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 21:01:06 -05:00
Pre-process file content to remove artifacts
This commit is contained in:
@@ -925,6 +925,16 @@ export class ClaudeDev {
|
|||||||
fileExists = await fileExistsAtPath(absolutePath)
|
fileExists = await fileExistsAtPath(absolutePath)
|
||||||
this.diffViewProvider.editType = fileExists ? "modify" : "create"
|
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 = {
|
const sharedMessageProps: ClaudeSayTool = {
|
||||||
tool: fileExists ? "editedExistingFile" : "newFileCreated",
|
tool: fileExists ? "editedExistingFile" : "newFileCreated",
|
||||||
path: getReadablePath(cwd, removeClosingTag("path", relPath)),
|
path: getReadablePath(cwd, removeClosingTag("path", relPath)),
|
||||||
@@ -1596,7 +1606,7 @@ export class ClaudeDev {
|
|||||||
// stream did not complete tool call, add it as partial
|
// stream did not complete tool call, add it as partial
|
||||||
if (currentParamName) {
|
if (currentParamName) {
|
||||||
// tool call has a parameter that was not completed
|
// 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)
|
toolUses.push(currentToolUse)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user