diff --git a/cli2.js b/cli2.js index fd75d77..d135e89 100644 --- a/cli2.js +++ b/cli2.js @@ -10,10 +10,10 @@ import chalk from 'chalk'; const modelDialog = new ModelDialog(); modelDialog.on('outputUpdate', (output) => { - console.log(chalk.blue('output event'),output); + //console.log(chalk.blue('output event'),output); }); modelDialog.on('reasoningUpdate', (output) => { - console.log(chalk.blue('reasoning event'),output); + //console.log(chalk.blue('reasoning event'),output); }); diff --git a/modelDialog.js b/modelDialog.js index 51b6bb1..5040091 100644 --- a/modelDialog.js +++ b/modelDialog.js @@ -135,10 +135,7 @@ class ModelDialog { const limitedArgs = typeof toolCall.arguments === 'string' ? (toolCall.arguments.length > 400 ? toolCall.arguments.slice(0, 400) + '...[truncated]' : toolCall.arguments) : toolCall.arguments; - console.log( - chalk.green('tool call:'), - { ...toolCall, arguments: limitedArgs } - ); + const tool = toolsByFile[toolCall.name]; let args; try{ @@ -153,7 +150,7 @@ class ModelDialog { continue; } const result = await tool.run(args); - console.log(chalk.green('function call result:'),'',toolCall.name,'\n','',args,'\n','',result,''); + console.log(chalk.green('function call result:'),'',toolCall.name,'\n','',limitedArgs,'\n','',JSON.stringify(result).slice(0,100),'...'); this.messages.push({ type: "function_call_output", call_id: toolCall.call_id, diff --git a/tools/patch_files.js b/tools/patch_files.js index 8dc1eda..1a8ac2d 100644 --- a/tools/patch_files.js +++ b/tools/patch_files.js @@ -6,7 +6,7 @@ but the format of the diff specification is unique to this task, so pay careful To use the 'apply_patch' command, you should pass a message of the following structure as "input": *** Begin Patch -[YOUR_PATH] +[YOUR_PATCH] *** End Patch Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format. @@ -36,8 +36,17 @@ For instructions on [context_before] and [context_after]: + [new_code] [3 lines of post-context] -Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below. -`; +Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. + +Complese Example: +*** Begin Patch +*** Add File: /test.js ++ function method() { ++ console.log("Hello, world!"); ++ } +*** End Patch +`; + // --------------------------------------------------------------------------- // // Domain objects // --------------------------------------------------------------------------- // diff --git a/tools/read_file.js b/tools/read_file.js index 0285a70..84ff6ba 100644 --- a/tools/read_file.js +++ b/tools/read_file.js @@ -1,6 +1,6 @@ import { createReadStream } from "node:fs"; import { createInterface } from "node:readline"; - +import fs from "node:fs"; import path from "node:path"; const virtual_chroot = '/workspaces/aiTools/root'; @@ -30,7 +30,10 @@ export async function run(args) { // Normalize linesToRead (1-400, with 0 or >400 meaning 400) const maxLines = (linesToRead <= 0 || linesToRead > 400) ? 400 : linesToRead; - // return 'FILE DOES NOT EXIST' + // check if the file exists + if (!fs.existsSync(fullPath)) { + return `read_file error: File does not exist`; + } try { @@ -53,7 +56,7 @@ export async function run(args) { } } - return lines.join('\n'); + return 'Filecontent: ´´´'+lines.join('')+'´´´'; } catch (error) { return `read_file error: ${error.message}`; }