mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Fixes
This commit is contained in:
@@ -107,6 +107,13 @@ export class OpenRouterHandler implements ApiHandler {
|
|||||||
text: delta.content,
|
text: delta.content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (chunk.usage) {
|
||||||
|
yield {
|
||||||
|
type: "usage",
|
||||||
|
inputTokens: chunk.usage.prompt_tokens || 0,
|
||||||
|
outputTokens: chunk.usage.completion_tokens || 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -121,10 +128,13 @@ export class OpenRouterHandler implements ApiHandler {
|
|||||||
console.log("OpenRouter generation details:", response.data)
|
console.log("OpenRouter generation details:", response.data)
|
||||||
yield {
|
yield {
|
||||||
type: "usage",
|
type: "usage",
|
||||||
inputTokens: generation?.native_tokens_prompt || 0,
|
|
||||||
outputTokens: generation?.native_tokens_completion || 0,
|
|
||||||
// cacheWriteTokens: 0,
|
// cacheWriteTokens: 0,
|
||||||
// cacheReadTokens: 0,
|
// cacheReadTokens: 0,
|
||||||
|
// openrouter generation endpoint fails often, so we'll report tokens from stream as normal
|
||||||
|
// inputTokens: generation?.native_tokens_prompt || 0,
|
||||||
|
// outputTokens: generation?.native_tokens_completion || 0,
|
||||||
|
inputTokens: 0,
|
||||||
|
outputTokens: 0,
|
||||||
totalCost: generation?.total_cost || 0,
|
totalCost: generation?.total_cost || 0,
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -973,6 +973,13 @@ export class Cline {
|
|||||||
newContent = newContent.split("\n").slice(0, -1).join("\n").trim()
|
newContent = newContent.split("\n").slice(0, -1).join("\n").trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.api.getModel().id.includes("llama") &&
|
||||||
|
(newContent.includes(">") || newContent.includes("<"))
|
||||||
|
) {
|
||||||
|
newContent = newContent.replace(/>/g, ">").replace(/</g, "<")
|
||||||
|
}
|
||||||
|
|
||||||
const sharedMessageProps: ClineSayTool = {
|
const sharedMessageProps: ClineSayTool = {
|
||||||
tool: fileExists ? "editedExistingFile" : "newFileCreated",
|
tool: fileExists ? "editedExistingFile" : "newFileCreated",
|
||||||
path: getReadablePath(cwd, removeClosingTag("path", relPath)),
|
path: getReadablePath(cwd, removeClosingTag("path", relPath)),
|
||||||
|
|||||||
@@ -13,25 +13,7 @@ export const formatResponse = {
|
|||||||
noToolsUsed: () =>
|
noToolsUsed: () =>
|
||||||
`[ERROR] You did not use a tool in your previous response! Please retry with a tool use.
|
`[ERROR] You did not use a tool in your previous response! Please retry with a tool use.
|
||||||
|
|
||||||
# Instructions for Tool Use
|
${toolUseInstructionsReminder}
|
||||||
|
|
||||||
Tool uses are formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
|
||||||
|
|
||||||
<tool_name>
|
|
||||||
<parameter1_name>value1</parameter1_name>
|
|
||||||
<parameter2_name>value2</parameter2_name>
|
|
||||||
...
|
|
||||||
</tool_name>
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
<attempt_completion>
|
|
||||||
<result>
|
|
||||||
I have completed the task...
|
|
||||||
</result>
|
|
||||||
</attempt_completion>
|
|
||||||
|
|
||||||
Always adhere to this format for all tool uses to ensure proper parsing and execution.
|
|
||||||
|
|
||||||
# Next Steps
|
# Next Steps
|
||||||
|
|
||||||
@@ -44,7 +26,7 @@ Otherwise, if you have not completed the task and do not need additional informa
|
|||||||
`You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n<feedback>\n${feedback}\n</feedback>`,
|
`You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n<feedback>\n${feedback}\n</feedback>`,
|
||||||
|
|
||||||
missingToolParameterError: (paramName: string) =>
|
missingToolParameterError: (paramName: string) =>
|
||||||
`Missing value for required parameter '${paramName}'. Please retry with complete response.`,
|
`Missing value for required parameter '${paramName}'. Please retry with complete response.\n\n${toolUseInstructionsReminder}`,
|
||||||
|
|
||||||
toolResult: (
|
toolResult: (
|
||||||
text: string,
|
text: string,
|
||||||
@@ -126,3 +108,23 @@ const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[]
|
|||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toolUseInstructionsReminder = `# Reminder: Instructions for Tool Use
|
||||||
|
|
||||||
|
Tool uses are formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure:
|
||||||
|
|
||||||
|
<tool_name>
|
||||||
|
<parameter1_name>value1</parameter1_name>
|
||||||
|
<parameter2_name>value2</parameter2_name>
|
||||||
|
...
|
||||||
|
</tool_name>
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
<attempt_completion>
|
||||||
|
<result>
|
||||||
|
I have completed the task...
|
||||||
|
</result>
|
||||||
|
</attempt_completion>
|
||||||
|
|
||||||
|
Always adhere to this format for all tool uses to ensure proper parsing and execution.`
|
||||||
|
|||||||
Reference in New Issue
Block a user